3.5.6 Real Types
Real types provide approximations
to the real numbers, with relative bounds on errors for floating point
types, and with absolute bounds for fixed point types.
Syntax
Static Semantics
A type defined by a
real_type_definition
is implicitly derived from
root_real, an anonymous predefined
(specific) real type. Hence, all real types, whether floating point or
fixed point, are in the derivation class rooted at
root_real.
Real literals
are all of the type
universal_real, the universal type (see
3.4.1)
for the class rooted at
root_real, allowing their use with the
operations of any real type.
Certain multiplying
operators have a result type of
universal_fixed (see
4.5.5),
the universal type for the class of fixed point types, allowing the result
of the multiplication or division to be used where any specific fixed
point type is expected.
Dynamic Semantics
Implementation Requirements
An implementation shall perform the run-time evaluation
of a use of a predefined operator of
root_real with an accuracy
at least as great as that of any floating point type definable by a
floating_point_definition.
Implementation Permissions
For the execution of a predefined operation of a
real type, the implementation need not raise Constraint_Error if the
result is outside the base range of the type, so long as the correct
result is produced, or the Machine_Overflows attribute of the type is
False (see
G.2).
An implementation may provide
nonstandard real types, descendants of
root_real that are
declared outside of the specification of package Standard, which need
not have all the standard characteristics of a type defined by a
real_type_definition.
For example, a nonstandard real type might have an asymmetric or unsigned
base range, or its predefined operations might wrap around or “saturate”
rather than overflow (modular or saturating arithmetic), or it might
not conform to the accuracy model (see
G.2).
Any type descended from a nonstandard real type is also nonstandard.
An implementation may place arbitrary restrictions on the use of such
types; it is implementation defined whether operators that are predefined
for “any real type” are defined for a particular nonstandard
real type. In any case, such types are not permitted as
explicit_generic_actual_parameters
for formal scalar types — see
12.5.2.
40 As stated, real literals are of the
anonymous predefined real type
universal_real. Other real types
have no literals. However, the overload resolution rules (see
8.6)
allow expressions of the type
universal_real whenever a real type
is expected.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe