From ac02cce7c3438d617770bcda17f97a5241c1709d Mon Sep 17 00:00:00 2001 From: Antoine Soulier Date: Thu, 25 Apr 2024 10:41:44 -0700 Subject: [PATCH] fastmath: Prefer signed addition instead of unsigned wrapped --- src/fastmath.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastmath.h b/src/fastmath.h index 221d69f..c61ae64 100644 --- a/src/fastmath.h +++ b/src/fastmath.h @@ -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; }