diff mbox series

[Ada] Small adjustment to System.Val_Real

Message ID 20201215114241.GA35303@adacore.com
State New
Headers show
Series [Ada] Small adjustment to System.Val_Real | expand

Commit Message

Pierre-Marie de Rodat Dec. 15, 2020, 11:42 a.m. UTC
This recovers a few bits of precision by always using the Extra digit.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-valrea.adb (Integer_to_Real): Always use Extra.
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/s-valrea.adb b/gcc/ada/libgnat/s-valrea.adb
--- a/gcc/ada/libgnat/s-valrea.adb
+++ b/gcc/ada/libgnat/s-valrea.adb
@@ -82,13 +82,12 @@  package body System.Val_Real is
          System.Float_Control.Reset;
       end if;
 
-      --  Take into account the extra digit near the limit to avoid anomalies
+      --  Take into account the extra digit
 
-      if Extra > 0 and then Val <= Precision_Limit / Uns (Base) then
-         R_Val := Num (Val * Uns (Base)) + Num (Extra);
+      R_Val := Num (Val);
+      if Extra > 0 then
+         R_Val := R_Val * Num (Base) + Num (Extra);
          S := S - 1;
-      else
-         R_Val := Num (Val);
       end if;
 
       --  Compute the final value