https://gcc.gnu.org/g:3ea199a18919585285745c1c71cf9cb53a17d689

commit r15-6188-g3ea199a18919585285745c1c71cf9cb53a17d689
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Tue Nov 26 11:25:54 2024 +0100

    ada: Adjust cut-off for scaling of floating-point numbers
    
    The value needs to take into account denormals and encompass Maxdigs.
    
    gcc/ada/ChangeLog:
    
            * libgnat/s-imager.adb (Maxscaling): Change to Natural constant and
            add Maxdigs to value.

Diff:
---
 gcc/ada/libgnat/s-imager.adb | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/libgnat/s-imager.adb b/gcc/ada/libgnat/s-imager.adb
index d19fda3b613d..89f9c1b020a3 100644
--- a/gcc/ada/libgnat/s-imager.adb
+++ b/gcc/ada/libgnat/s-imager.adb
@@ -49,14 +49,13 @@ package body System.Image_R is
 
    Maxdigs : constant Natural := 2 * Natural'Min (Uns'Width - 2, Num'Digits);
 
-   Maxscaling : constant := 5000;
-   --  Max decimal scaling required during conversion of floating-point
-   --  numbers to decimal. This is used to defend against infinite
-   --  looping in the conversion, as can be caused by erroneous executions.
-   --  The largest exponent used on any current system is 2**16383, which
-   --  is approximately 10**4932, and the highest number of decimal digits
-   --  is about 35 for 128-bit floating-point formats, so 5000 leaves
-   --  enough room for scaling such values
+   Maxscaling : constant Natural := 5000 + Maxdigs;
+   --  Maximum decimal scaling required during conversion of floating-point
+   --  numbers to decimal. This is used to defend against infinite looping
+   --  during the conversion, that could be caused by erroneous execution.
+   --  The largest decimal exponent in absolute value used on any current
+   --  system is 4966 (denormals of IEEE binary128) and we scale up to the
+   --  Maxdigs exponent during the conversion.
 
    package Double_Real is new System.Double_Real (Num);
    use type Double_Real.Double_T;

Reply via email to