aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/s-exponr.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-03-03 20:15:42 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-16 04:43:04 -0400
commitf4fe186bfe3e74c7c9b2d49b635565ea9a4df1b2 (patch)
treed05d7cef7094ef78e900aa25cd6e0749dc094ab8 /gcc/ada/libgnat/s-exponr.adb
parent07b7dc09b21d1a2f000f2861a87b017b764b38b4 (diff)
downloadgcc-f4fe186bfe3e74c7c9b2d49b635565ea9a4df1b2.zip
gcc-f4fe186bfe3e74c7c9b2d49b635565ea9a4df1b2.tar.gz
gcc-f4fe186bfe3e74c7c9b2d49b635565ea9a4df1b2.tar.bz2
[Ada] Fix floating-point exponentiation with Integer'First exponent
gcc/ada/ * urealp.adb (Scale): Change first paramter to Uint and adjust. (Equivalent_Decimal_Exponent): Pass U.Den directly to Scale. * libgnat/s-exponr.adb (Negative): Rename to... (Safe_Negative): ...this and change its lower bound. (Exponr): Adjust to above renaming and deal with Integer'First.
Diffstat (limited to 'gcc/ada/libgnat/s-exponr.adb')
-rw-r--r--gcc/ada/libgnat/s-exponr.adb9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/ada/libgnat/s-exponr.adb b/gcc/ada/libgnat/s-exponr.adb
index ece53b5..ad7f401 100644
--- a/gcc/ada/libgnat/s-exponr.adb
+++ b/gcc/ada/libgnat/s-exponr.adb
@@ -57,8 +57,8 @@ function System.Exponr (Left : Num; Right : Integer) return Num is
subtype Double_T is Double_Real.Double_T;
-- The double floating-point type
- subtype Negative is Integer range Integer'First .. -1;
- -- The range of negative exponents
+ subtype Safe_Negative is Integer range Integer'First + 1 .. -1;
+ -- The range of safe negative exponents
function Expon (Left : Num; Right : Natural) return Num;
-- Routine used if Right is greater than 4
@@ -113,9 +113,12 @@ begin
return Num'Machine (Sqr * Sqr);
end;
- when Negative =>
+ when Safe_Negative =>
return Num'Machine (1.0 / Exponr (Left, -Right));
+ when Integer'First =>
+ return Num'Machine (1.0 / (Exponr (Left, Integer'Last) * Left));
+
when others =>
return Num'Machine (Expon (Left, Right));
end case;