G.2.2 Model-Oriented Attributes of Floating Point Types
In implementations that support the Numerics Annex,
the model-oriented attributes of floating point types shall yield the
values defined here, in both the strict and the relaxed modes. These
definitions add conditions to those in
A.5.3.
Static Semantics
For every subtype S
of a floating point type T:
Yields the number of digits in the mantissa of the canonical form of
the model numbers of
T (see
A.5.3).
The value of this attribute shall be greater than or equal to
Ceiling(d · log(10) / log(T'Machine_Radix)) + g
where d
is the requested decimal precision of T, and g
is 0 if T'Machine_Radix is a positive power of 10 and 1 otherwise.
In addition, T'Model_Mantissa shall be less than or equal to the
value of T'Machine_Mantissa. This attribute yields a value of
the type universal_integer.
Ramification: S'Model_Epsilon, which
is defined in terms of S'Model_Mantissa (see
A.5.3),
yields the absolute value of the difference between one and the next
model number of the type
T above one. It is equal to or larger
than the absolute value of the difference between one and the next machine
number of the type
T above one.
Yields the minimum exponent of the canonical form of the model numbers
of
T (see
A.5.3). The value of this
attribute shall be greater than or equal to the value of
T'Machine_Emin.
This attribute yields a value of the type
universal_integer.
Ramification: S'Model_Small, which is
defined in terms of S'Model_Emin (see
A.5.3),
yields the smallest positive (nonzero) model number of the type
T.
Yields the lower bound of the safe range of
T. The value of this
attribute shall be a model number of
T and greater than or equal
to the lower bound of the base range of
T. In addition, if
T
is declared by a
floating_point_definition
or is derived from such a type, and the
floating_point_definition
includes a
real_range_specification
specifying a lower bound of
lb, then
the value of this attribute shall be less than or equal to
lb;
otherwise, it shall be less than or equal to –10.0
4
· d,
where
d is the requested decimal precision
of
T. This attribute yields a value of the type
universal_real.
Yields the upper bound of the safe range of
T. The value of this
attribute shall be a model number of
T and less than or equal
to the upper bound of the base range of
T. In addition, if
T
is declared by a
floating_point_definition
or is derived from such a type, and the
floating_point_definition
includes a
real_range_specification
specifying an upper bound of
ub, then
the value of this attribute shall be greater than or equal to
ub;
otherwise, it shall be greater than or equal to 10.0
4
· d,
where d is the requested decimal precision of
T. This attribute
yields a value of the type
universal_real.
{Constraint_Error
(raised by failure of run-time check)} S'
Model
Denotes a function (of a parameter
X) whose specification is given
in
A.5.3. If
X is a model number of
T, the function yields
X; otherwise, it yields the value
obtained by rounding or truncating
X to either one of the adjacent
model numbers of
T.
{Overflow_Check
[partial]} {check,
language-defined (Overflow_Check)} Constraint_Error
is raised if the resulting model number is outside the safe range of
S. A zero result has the sign of
X when S'Signed_Zeros is True.
Subject to the constraints
given above, the values of S'Model_Mantissa and S'Safe_Last are to be
maximized, and the values of S'Model_Emin and S'Safe_First minimized,
by the implementation as follows:
First, S'Model_Mantissa is set to the largest value
for which values of S'Model_Emin, S'Safe_First, and S'Safe_Last can be
chosen so that the implementation satisfies the strict-mode requirements
of
G.2.1 in terms of the model numbers and
safe range induced by these attributes.
Next, S'Model_Emin is set to the smallest value
for which values of S'Safe_First and S'Safe_Last can be chosen so that
the implementation satisfies the strict-mode requirements of
G.2.1
in terms of the model numbers and safe range induced by these attributes
and the previously determined value of S'Model_Mantissa.
Finally, S'Safe_First and S'Safe_last are set (in
either order) to the smallest and largest values, respectively, for which
the implementation satisfies the strict-mode requirements of
G.2.1
in terms of the model numbers and safe range induced by these attributes
and the previously determined values of S'Model_Mantissa and S'Model_Emin.
Ramification: {
IEEE floating point
arithmetic}
{
IEC 559:1989}
The
following table shows appropriate attribute values for IEEE basic single
and double precision types (ANSI/IEEE Std 754-1985, IEC 559:1989). Here,
we use the names IEEE_Float_32 and IEEE_Float_64, the names that would
typically be declared in package Interfaces, in an implementation that
supports IEEE arithmetic. In such an implementation, the attributes would
typically be the same for Standard.Float and Long_Float, respectively.
Attribute IEEE_Float_32 IEEE_Float_64
'Machine_Radix 2 2
'Machine_Mantissa 24 53
'Machine_Emin -125 -1021
'Machine_Emax 128 1024
'Denorm True True
'Machine_Rounds True True
'Machine_Overflows True/False True/False
'Signed_Zeros should be True should be True
'Model_Mantissa (same as 'Machine_Mantissa) (same as 'Machine_Mantissa)
'Model_Emin (same as 'Machine_Emin) (same as 'Machine_Emin)
'Model_Epsilon 2.0**(-23) 2.0**(-52)
'Model_Small 2.0**(-126) 2.0**(-1022)
'Safe_First -2.0**128*(1.0-2.0**(-24)) -2.0**1024*(1.0-2.0**(-53))
'Safe_Last 2.0**128*(1.0-2.0**(-24)) 2.0**1024*(1.0-2.0**(-53))
'Digits 6 15
'Base'Digits (same as 'Digits) (same as 'Digits)
'First (same as 'Safe_First) (same as 'Safe_First)
'Last (same as 'Safe_Last) (same as 'Safe_Last)
'Size 32 64
Note: 'Machine_Overflows can be True or False,
depending on whether the Ada implementation raises Constraint_Error or
delivers a signed infinity in overflow and zerodivide situations (and
at poles of the elementary functions).
Wording Changes from Ada 95