Annotated Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

G.2.2 Model-Oriented Attributes of Floating Point Types

1
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

2
For every subtype S of a floating point type T
3/2
{AI95-00256-01} S'Model_Mantissa 

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)) + 1, where d is the requested decimal precision of T. In addition, it shall be less than or equal to the value of T'Machine_Mantissa. This attribute yields a value of the type universal_integer. 
3.1/2
Ceiling(d · log(10) / log(T'Machine_Radix)) + g
3.2/2
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. 
3.a
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. 
4
S'Model_Emin
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
4.a
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.
5
S'Safe_First
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.
6
S'Safe_Last
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.
7
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. 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.
8
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: 
9
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.
10
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.
11/3
{AI05-0092-1} Finally, S'Safe_First and S'Safe_Last 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. 
11.a
Ramification: 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.
11.b
Attribute                        IEEE_Float_32                 IEEE_Float_64
11.c
'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
11.d
'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))
11.e
'Digits                                      6                            15
'Base'Digits                 (same as 'Digits)             (same as 'Digits)
11.f
'First                   (same as 'Safe_First)         (same as 'Safe_First)
'Last                     (same as 'Safe_Last)          (same as 'Safe_Last)
'Size                                       32                            64
11.g
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

11.h/2
{AI95-00256-01} Corrected the definition of Model_Mantissa to match that given in 3.5.8. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe