From 5312f5eddd8264c27f0b237da17193ff3674dfd1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 15 Aug 2025 10:24:45 +0100 Subject: [PATCH] Added explicit check for remainder in divide_round_to_infinity --- include/etl/rounded_integral_division.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/rounded_integral_division.h b/include/etl/rounded_integral_division.h index 4f0427ad..cdd0f16b 100644 --- a/include/etl/rounded_integral_division.h +++ b/include/etl/rounded_integral_division.h @@ -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; } }