COMMON: Fix UB shifting negative integers
Compilers optimise these back into shifts on architectures where shifts of negative integers work the same as mul/div, so this solves the UB without actually causing any performance issue.
This commit is contained in:
parent
9a36870e78
commit
02614f2f1a
1 changed files with 2 additions and 2 deletions
|
@ -46,7 +46,7 @@ typedef int32 frac_t;
|
|||
inline frac_t doubleToFrac(double value) { return (frac_t)(value * FRAC_ONE); }
|
||||
inline double fracToDouble(frac_t value) { return ((double)value) / FRAC_ONE; }
|
||||
|
||||
inline frac_t intToFrac(int16 value) { return value << FRAC_BITS; }
|
||||
inline int16 fracToInt(frac_t value) { return value >> FRAC_BITS; }
|
||||
inline frac_t intToFrac(int16 value) { return value * (1 << FRAC_BITS); }
|
||||
inline int16 fracToInt(frac_t value) { return value / (1 << FRAC_BITS); }
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue