FixedDiv2: divide numerator before taking absolute value to avoid INT32_MIN overflow to 0

This commit is contained in:
James R 2022-09-14 22:38:12 -07:00
parent 81a4cb17c0
commit ef0ff01ef1

View file

@ -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);