Skip to content

Commit

Permalink
fastmath: Prefer signed addition instead of unsigned wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
asoulier committed Apr 25, 2024
1 parent 73bbc00 commit ac02cce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/fastmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
* return 2^exp
*/
static inline float lc3_ldexpf(float _x, int exp) {
union { float f; uint32_t u; } x = { .f = _x };
union { float f; int32_t s; } x = { .f = _x };

if (x.u & LC3_IEEE754_EXP_MASK)
x.u += exp << LC3_IEEE754_EXP_SHL;
if (x.s & LC3_IEEE754_EXP_MASK)
x.s += exp << LC3_IEEE754_EXP_SHL;

return x.f;
}
Expand Down

0 comments on commit ac02cce

Please sign in to comment.