From: Eric Botcazou Date: Wed, 2 Apr 2025 11:13:33 +0000 (+0200) Subject: ada: Fix rounding test with odd bases X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa6a71aac7eee3ad1597759724992ee1f65ee87f;p=thirdparty%2Fgcc.git ada: Fix rounding test with odd bases The test as currently written is incorrect for odd bases. gcc/ada/ChangeLog: * libgnat/s-valuer.adb (Round_Extra): Use multiplicative test. --- diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb index 6f557e93207..93e292cc34f 100644 --- a/gcc/ada/libgnat/s-valuer.adb +++ b/gcc/ada/libgnat/s-valuer.adb @@ -135,7 +135,9 @@ package body System.Value_R is B : constant Uns := Uns (Base); begin - if Digit >= Base / 2 then + -- Beware that Base may be odd + + if 2 * Unsigned (Digit) >= Base then -- If Extra is maximum, round Value