Ada Reference Manual — Legal Information

A.5.3 Attributes of Floating Point Types

Static Semantics

representation-oriented attributes are defined for every subtype S of a floating point type T. The followingare defined for every subtype S of a floating point type

S'Machine_Radix



T. The value of this attribute is of the type universal_integer. Yields the radix of the hardware representation of the type. The value of this attribute is of the type

canonical form. The canonical form (for the type T) is the form

± mantissa · T 'Machine_Radix exponent

where The values of other representation-oriented attributes of a floating point subtype, and of the “primitive function” attributes of a floating point subtype described later, are defined in terms of a particular representation of nonzero values called the. The canonical form (for the type) is the formwhere

mantissa is a fraction in the number base T'Machine_Radix, the first digit of which is nonzero, and

exponent is an integer.

S'Machine_Mantissa



p such that every value expressible in the canonical form (for the type T), having a p -digit mantissa and an exponent between T'Machine_Emin and T'Machine_Emax, is a machine number (see T. This attribute yields a value of the type universal_integer. Yields the largest value ofsuch that every value expressible in the canonical form (for the type), having a-digitand anbetween'Machine_Emin and'Machine_Emax, is a machine number (see 3.5.7 ) of the type. This attribute yields a value of the type

S'Machine_Emin



exponent such that every value expressible in the canonical form (for the type T), having a mantissa of T'Machine_Mantissa digits, is a machine number (see T. This attribute yields a value of the type universal_integer. Yields the smallest (most negative) value ofsuch that every value expressible in the canonical form (for the type), having aof'Machine_Mantissa digits, is a machine number (see 3.5.7 ) of the type. This attribute yields a value of the type

S'Machine_Emax



exponent such that every value expressible in the canonical form (for the type T), having a mantissa of T'Machine_Mantissa digits, is a machine number (see T. This attribute yields a value of the type universal_integer. Yields the largest (most positive) value ofsuch that every value expressible in the canonical form (for the type), having aof'Machine_Mantissa digits, is a machine number (see 3.5.7 ) of the type. This attribute yields a value of the type

S'Denorm



± mantissa · T 'Machine_Radix T 'Machine_Emin

where mantissa is a nonzero T'Machine_Mantissa-digit fraction in the number base T'Machine_Radix, the first digit of which is zero, is a machine number (see T; yields the value False otherwise. The value of this attribute is of the predefined type Boolean. Yields the value True if every value expressible in the formwhereis a nonzero'Machine_Mantissa-digit fraction in the number base'Machine_Radix, the first digit of which is zero, is a machine number (see 3.5.7 ) of the type; yields the value False otherwise. The value of this attribute is of the predefined type Boolean.

denormalized numbers. normalized number. x of a given type T is said to be represented in canonical form when it is expressed in the canonical form (for the type T) with a mantissa having T'Machine_Mantissa digits; the resulting form is the canonical-form representation of x . The values described by the formula in the definition of S'Denorm are called A nonzero machine number that is not a denormalized number is a A normalized numberof a given typeis said to bewhen it is expressed in the canonical form (for the type) with ahaving'Machine_Mantissa digits; the resulting form is theof

S'Machine_Rounds



T; yields the value False otherwise. The value of this attribute is of the predefined type Boolean. Yields the value True if rounding is performed on inexact results of every predefined operation that yields a result of the type; yields the value False otherwise. The value of this attribute is of the predefined type Boolean.

S'Machine_Overflows



T; yields the value False otherwise. The value of this attribute is of the predefined type Boolean. Yields the value True if overflow and divide-by-zero are detected and reported by raising Constraint_Error for every predefined operation that yields a result of the type; yields the value False otherwise. The value of this attribute is of the predefined type Boolean.

S'Signed_Zeros



T has the capability of representing both positively and negatively signed zeros, these being generated and used by the predefined operations of the type T as specified in IEC 559:1989; yields the value False otherwise. The value of this attribute is of the predefined type Boolean. Yields the value True if the hardware representation for the typehas the capability of representing both positively and negatively signed zeros, these being generated and used by the predefined operations of the typeas specified in IEC 559:1989; yields the value False otherwise. The value of this attribute is of the predefined type Boolean.

x of a floating point type T, the normalized exponent of x is defined as follows: For every valueof a floating point type, theofis defined as follows:

the normalized exponent of zero is (by convention) zero;

for nonzero x , the normalized exponent of x is the unique integer k such that T 'Machine_Radix k –1 ≤ | x | < T 'Machine_Radix k .

primitive function attributes are defined for any subtype S of a floating point type T. The followingare defined for any subtype S of a floating point type

S'Exponent

S'Exponent denotes a function with the following specification:

function S'Exponent ( X : T )

return universal_integer

The function yields the normalized exponent of X.

S'Fraction

S'Fraction denotes a function with the following specification:

function S'Fraction ( X : T )

return T

The function yields the value X · T 'Machine_Radix – k , where k is the normalized exponent of X. A zero result, which can only occur when X is zero, has the sign of X.

S'Compose

S'Compose denotes a function with the following specification:

function S'Compose ( Fraction : T ;

Exponent : universal_integer )

return T

v be the value Fraction · T 'Machine_Radix Exponent – k , where k is the normalized exponent of Fraction. If v is a machine number of the type T, or if | v | ≥ T 'Model_Small , the function yields v ; otherwise, it yields either one of the machine numbers of the type T adjacent to v . v is outside the base range of S. A zero result has the sign of Fraction when S'Signed_Zeros is True. Letbe the value, whereis the normalized exponent of. Ifis a machine number of the type, or if || ≥, the function yields; otherwise, it yields either one of the machine numbers of the typeadjacent to Constraint_Error is optionally raised ifis outside the base range of S. A zero result has the sign ofwhen S'Signed_Zeros is True.

S'Scaling

S'Scaling denotes a function with the following specification:

function S'Scaling ( X : T ;

Adjustment : universal_integer )

return T

v be the value X · T 'Machine_Radix Adjustment . If v is a machine number of the type T, or if | v | ≥ T 'Model_Small , the function yields v ; otherwise, it yields either one of the machine numbers of the type T adjacent to v . v is outside the base range of S. A zero result has the sign of X when S'Signed_Zeros is True. Letbe the value. Ifis a machine number of the type, or if || ≥, the function yields; otherwise, it yields either one of the machine numbers of the typeadjacent to Constraint_Error is optionally raised ifis outside the base range of S. A zero result has the sign ofwhen S'Signed_Zeros is True.

S'Floor

S'Floor denotes a function with the following specification:

function S'Floor ( X : T )

return T

The function yields the value Floor( X ), i.e., the largest (most positive) integral value less than or equal to X. When X is zero, the result has the sign of X; a zero result otherwise has a positive sign.

S'Ceiling

S'Ceiling denotes a function with the following specification:

function S'Ceiling ( X : T )

return T

The function yields the value Ceiling( X ), i.e., the smallest (most negative) integral value greater than or equal to X. When X is zero, the result has the sign of X; a zero result otherwise has a negative sign when S'Signed_Zeros is True.

S'Rounding

S'Rounding denotes a function with the following specification:

function S'Rounding ( X : T )

return T

The function yields the integral value nearest to X, rounding away from zero if X lies exactly halfway between two integers. A zero result has the sign of X when S'Signed_Zeros is True.

S'Unbiased_Rounding



S'Unbiased_Rounding denotes a function with the following specification:

function S'Unbiased_Rounding ( X : T )

return T

The function yields the integral value nearest to X, rounding toward the even integer if X lies exactly halfway between two integers. A zero result has the sign of X when S'Signed_Zeros is True.

S'Machine_Rounding



S'Machine_Rounding denotes a function with the following specification:

function S'Machine_Rounding ( X : T )

return T

X. If X lies exactly halfway between two integers, one of those integers is returned, but which of them is returned is unspecified. A zero result has the sign of X when S'Signed_Zeros is True. This function provides access to the rounding behavior which is most efficient on the target processor. The function yields the integral value nearest to. Iflies exactly halfway between two integers, one of those integers is returned, but which of them is returned is unspecified. A zero result has the sign ofwhen S'Signed_Zeros is True. This function provides access to the rounding behavior which is most efficient on the target processor.

S'Truncation

S'Truncation denotes a function with the following specification:

function S'Truncation ( X : T )

return T

The function yields the value Ceiling( X ) when X is negative, and Floor( X ) otherwise. A zero result has the sign of X when S'Signed_Zeros is True.

S'Remainder

S'Remainder denotes a function with the following specification:

function S'Remainder ( X , Y : T )

return T

Y, let v be the value X – n · Y , where n is the integer nearest to the exact value of X / Y ; if | n – X / Y | = 1/2, then n is chosen to be even. If v is a machine number of the type T, the function yields v ; otherwise, it yields zero. Y is zero. A zero result has the sign of X when S'Signed_Zeros is True. For nonzero, letbe the value, whereis the integer nearest to the exact value of; if || = 1/2, thenis chosen to be even. Ifis a machine number of the type, the function yields; otherwise, it yields zero. Constraint_Error is raised ifis zero. A zero result has the sign ofwhen S'Signed_Zeros is True.

S'Adjacent

S'Adjacent denotes a function with the following specification:

function S'Adjacent ( X , Towards : T )

return T

Towards = X , the function yields X; otherwise, it yields the machine number of the type T adjacent to X in the direction of Towards, if that machine number exists. T'Signed_Zeros is True, a zero result has the sign of X. When Towards is zero, its sign has no bearing on the result. If, the function yields; otherwise, it yields the machine number of the typeadjacent toin the direction of, if that machine number exists. If the result would be outside the base range of S, Constraint_Error is raised. When'Signed_Zeros is True, a zero result has the sign of. Whenis zero, its sign has no bearing on the result.

S'Copy_Sign

S'Copy_Sign denotes a function with the following specification:

function S'Copy_Sign ( Value , Sign : T )

return T

Value is nonzero, the function yields a result whose magnitude is that of Value and whose sign is that of Sign; otherwise, it yields the value zero. Sign when S'Signed_Zeros is True. If the value ofis nonzero, the function yields a result whose magnitude is that ofand whose sign is that of; otherwise, it yields the value zero. Constraint_Error is optionally raised if the result is outside the base range of S. A zero result has the sign ofwhen S'Signed_Zeros is True.

S'Leading_Part



S'Leading_Part denotes a function with the following specification:

function S'Leading_Part ( X : T ;

Radix_Digits : universal_integer )

return T

Let v be the value T 'Machine_Radix k – Radix_Digits , where k is the normalized exponent of X. The function yields the value

Floor( X / v ) · v , when X is nonnegative and Radix_Digits is positive;

Ceiling( X / v ) · v , when X is negative and Radix_Digits is positive.

Radix_Digits is zero or negative. A zero result, which can only occur when X is zero, has the sign of X. Constraint_Error is raised whenis zero or negative. A zero result, which can only occur whenis zero, has the sign of

S'Machine

S'Machine denotes a function with the following specification:

function S'Machine ( X : T )

return T

X is a machine number of the type T, the function yields X; otherwise, it yields the value obtained by rounding or truncating X to either one of the adjacent machine numbers of the type T. X to the precision of the machine numbers results in a value outside the base range of S. A zero result has the sign of X when S'Signed_Zeros is True. Ifis a machine number of the type, the function yields; otherwise, it yields the value obtained by rounding or truncatingto either one of the adjacent machine numbers of the type Constraint_Error is raised if rounding or truncatingto the precision of the machine numbers results in a value outside the base range of S. A zero result has the sign ofwhen S'Signed_Zeros is True.

model-oriented attributes are defined for any subtype S of a floating point type T. The followingare defined for any subtype S of a floating point type

S'Model_Mantissa



Ceiling( d · log(10) / log( T ' Machine_Radix )) + 1, where d is the requested decimal precision of T, and less than or equal to the value of T'Machine_Mantissa. See universal_integer. If the Numerics Annex is not supported, this attribute yields an implementation defined value that is greater than or equal to· log(10) / log()) + 1, whereis the requested decimal precision of, and less than or equal to the value of'Machine_Mantissa. See G.2.2 for further requirements that apply to implementations supporting the Numerics Annex. The value of this attribute is of the type

S'Model_Emin

T'Machine_Emin. See universal_integer. If the Numerics Annex is not supported, this attribute yields an implementation defined value that is greater than or equal to the value of'Machine_Emin. See G.2.2 for further requirements that apply to implementations supporting the Numerics Annex. The value of this attribute is of the type

S'Model_Epsilon



T 'Machine_Radix 1 – T 'Model_Mantissa . The value of this attribute is of the type universal_real. Yields the value. The value of this attribute is of the type

S'Model_Small



T 'Machine_Radix T 'Model_Emin – 1 . The value of this attribute is of the type universal_real. Yields the value. The value of this attribute is of the type

S'Model

S'Model denotes a function with the following specification:

function S'Model ( X : T )

return T

If the Numerics Annex is not supported, the meaning of this attribute is implementation defined; see G.2.2 for the definition that applies to implementations supporting the Numerics Annex.

S'Safe_First

T. If the Numerics Annex is not supported, the value of this attribute is implementation defined; see universal_real. Yields the lower bound of the safe range (see 3.5.7 ) of the type. If the Numerics Annex is not supported, the value of this attribute is implementation defined; see G.2.2 for the definition that applies to implementations supporting the Numerics Annex. The value of this attribute is of the type

S'Safe_Last

T. If the Numerics Annex is not supported, the value of this attribute is implementation defined; see universal_real. Yields the upper bound of the safe range (see 3.5.7 ) of the type. If the Numerics Annex is not supported, the value of this attribute is implementation defined; see G.2.2 for the definition that applies to implementations supporting the Numerics Annex. The value of this attribute is of the type