From ef0ff01ef133740fa025146172a0fe48cb54eb1d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 14 Sep 2022 22:38:12 -0700 Subject: [PATCH] FixedDiv2: divide numerator before taking absolute value to avoid INT32_MIN overflow to 0 --- src/m_fixed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 9f3bb2910..021f84d89 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -204,7 +204,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a) */ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b) { - if ((abs(a) >> (FRACBITS-2)) >= abs(b)) + if ((abs(a / (FRACUNIT/4))) >= abs(b)) return (a^b) < 0 ? INT32_MIN : INT32_MAX; return FixedDiv2(a, b);