Num : constant Uint := Norm_Num (Small_Value (Rtyp));
Den : constant Uint := Norm_Den (Small_Value (Rtyp));
Max : constant Uint := UI_Max (Num, Den);
- Min : constant Uint := UI_Min (Num, Den);
Siz : constant Uint := Esize (Rtyp);
begin
if Siz <= 32
and then Max <= Uint_2 ** 31
- and then (Min = Uint_1 or else Max <= Uint_2 ** 27)
+ and then (Num = Uint_1 or else Max <= Uint_2 ** 27)
then
Vid := RE_Value_Fixed32;
elsif Siz <= 64
and then Max <= Uint_2 ** 63
- and then (Min = Uint_1 or else Max <= Uint_2 ** 59)
+ and then (Num = Uint_1 or else Max <= Uint_2 ** 59)
then
Vid := RE_Value_Fixed64;
elsif System_Max_Integer_Size = 128
and then Max <= Uint_2 ** 127
- and then (Min = Uint_1 or else Max <= Uint_2 ** 123)
+ and then (Num = Uint_1 or else Max <= Uint_2 ** 123)
then
Vid := RE_Value_Fixed128;
else
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**127)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**127)
- or else
(Num'Base'Small_Numerator <= 2**123
and then Num'Base'Small_Denominator <= 2**123));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**127)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**127)
- or else
(Num'Base'Small_Numerator <= 2**123
and then Num'Base'Small_Denominator <= 2**123));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**31)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**31)
- or else
(Num'Base'Small_Numerator <= 2**27
and then Num'Base'Small_Denominator <= 2**27));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**63)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**63)
- or else
(Num'Base'Small_Numerator <= 2**59
and then Num'Base'Small_Denominator <= 2**59));
-- These conditions are derived from the prerequisites of System.Value_F
((Num'Base'Small_Numerator = 1
and then Num'Base'Small_Denominator <= 2**127)
or else
- (Num'Base'Small_Denominator = 1
- and then Num'Base'Small_Numerator <= 2**127)
- or else
(Num'Base'Small_Numerator <= 2**123
and then Num'Base'Small_Denominator <= 2**123));
-- These conditions are derived from the prerequisites of System.Value_F
package body System.Value_F is
-- The prerequisite of the implementation is that the computation of the
- -- operands of the scaled divide does not unduly overflow when the small
- -- is neither an integer nor the reciprocal of an integer, which means
- -- that its numerator and denominator must be both not larger than the
- -- smallest divide 2**(Int'Size - 1) / Base where Base ranges over the
- -- supported values for the base of the literal. Given that the largest
- -- supported base is 16, this gives a limit of 2**(Int'Size - 5).
+ -- operands of the scaled divide does not unduly overflow, which means
+ -- that the numerator and the denominator of the small must be both not
+ -- larger than the smallest divide 2**(Int'Size - 1) / Base where Base
+ -- ranges over the supported values for the base of the literal, except
+ -- when the numerator is 1, in which case up to 2**(Int'Size - 1) is
+ -- permitted for the denominator. Given that the largest supported base
+ -- is 16, this gives a limit of 2**(Int'Size - 5) in the general case.
pragma Assert (Int'Size <= Uns'Size);
-- We need an unsigned type large enough to represent the mantissa
-- Num * (Base ** -ScaleB) <= Num * (B ** N) < Den * B
-- which means that the product does not overflow if Den <= 2**(M-1) / B.
+ -- Moreover, if 2**(M-1) / B < Den <= 2**(M-1), we can add 1 to ScaleB and
+ -- divide Val by B while preserving the rightmost B-digit of Val in Extra2
+ -- without changing the computation when Num = 1.
----------------------
-- Integer_To_Fixed --