Added explicit check for remainder in divide_round_to_infinity

This commit is contained in:
John Wellbelove 2025-08-15 10:24:45 +01:00
parent 8c49e67702
commit 5312f5eddd

View File

@ -274,12 +274,12 @@ namespace etl
if (private_rounded_integral_division::are_same_sign(numerator, denominator))
{
// Same sign, round towards +infinity
return remainder ? quotient + 1 : quotient;
return (remainder != 0) ? quotient + 1 : quotient;
}
else
{
// Different signs, round towards -infinity
return remainder ? quotient - 1 : quotient;
return (remainder != 0) ? quotient - 1 : quotient;
}
}