aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaruncz <marun1@email.cz>2021-04-27 11:08:33 +0200
committermaruncz <marun1@email.cz>2021-04-27 11:08:33 +0200
commitba0991de3e0c940f25986b2636db34f5871a41dd (patch)
tree35368c8c338172b3ccc04c9bdadad9b48ffc2bc4
parentb20bdb01d9da65bcffac57e116044060836142d1 (diff)
fixed: signed integer overflow is undefined behavior
-rw-r--r--libfixmath/fix16.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/libfixmath/fix16.h b/libfixmath/fix16.h
index c6be250..eeb0b99 100644
--- a/libfixmath/fix16.h
+++ b/libfixmath/fix16.h
@@ -87,7 +87,7 @@ static inline fix16_t fix16_from_dbl(double a)
#define F16(x) ((fix16_t)(((x) >= 0) ? ((x) * 65536.0 + 0.5) : ((x) * 65536.0 - 0.5)))
static inline fix16_t fix16_abs(fix16_t x)
- { return (x < 0 ? -x : x); }
+ { return (x < 0 ? -(uint32_t)x : x); }
static inline fix16_t fix16_floor(fix16_t x)
{ return (x & 0xFFFF0000UL); }
static inline fix16_t fix16_ceil(fix16_t x)