@@ -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;
@@ -270,23 +270,21 @@ package body Urealp is
15 => (Num => 53_385_559, Den => 45_392_361), -- 1.176091259055681
16 => (Num => 78_897_839, Den => 65_523_237)); -- 1.204119982655924
- function Scale (X : Int; R : Ratio) return Int;
+ function Scale (X : Uint; R : Ratio) return Int;
-- Compute the value of X scaled by R
-----------
-- Scale --
-----------
- function Scale (X : Int; R : Ratio) return Int is
- type Wide_Int is range -2**63 .. 2**63 - 1;
-
+ function Scale (X : Uint; R : Ratio) return Int is
begin
- return Int (Wide_Int (X) * Wide_Int (R.Num) / Wide_Int (R.Den));
+ return UI_To_Int (X * R.Num / R.Den);
end Scale;
begin
pragma Assert (U.Rbase /= 0);
- return Scale (UI_To_Int (U.Den), Logs (U.Rbase));
+ return Scale (U.Den, Logs (U.Rbase));
end Equivalent_Decimal_Exponent;
----------------