A.5.4 Attributes of Fixed Point Types
Static Semantics
The
following
representation-oriented attributes are defined for every
subtype S of a fixed point type
T.
S'Machine_Radix
Yields the radix of the hardware
representation of the type
T. The value
of this attribute is of the type
universal_integer.
S'Machine_Rounds
Yields the value True if rounding
is performed on inexact results of every predefined operation that yields
a result of the type
T; yields the
value False otherwise. The value of this attribute is of the predefined
type Boolean.
S'Machine_Overflows
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
T;
yields the value False otherwise. The value of this attribute is of the
predefined type Boolean.
A fixed point type
has integral values if
its Small value is an integer or the reciprocal of an integer. A generic
formal type is defined to have integral values.
The following primitive
function attributes are defined for every subtype S of a fixed point
type T that has integral values.
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),
that is, the smallest (most negative) integral value greater than or
equal to X.
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),
that is, the largest (most positive) integral value less than or equal
to X.
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.
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.
S'Machine_Rounding
S'Machine_Rounding denotes a
function with the following specification:
function S'Machine_Rounding (X : T)
return T
The function yields the integral value
nearest to
X. If
X
lies exactly halfway between two integers, one of those integers is returned,
but which of them is returned is unspecified. 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.
For all of these attributes, if
T
is a generic formal type, Program_Error is raised if the actual subtype
does not have integral values.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe