3.5.6 Real Types
{real type}
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
{root_real}
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.]
Ramification: It is not specified whether
the derivation from root_real is direct or indirect, not that
it really matters. All we want is for all real types to be descendants
of root_real.
[
{universal_real
[partial]} {real
literals} 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.
{universal_fixed
[partial]} 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.
Ramification: Static calculations using
the operators of
root_real are exact, as for all static calculations.
See
4.9.
Implementation Note: The Digits attribute
of the type used to represent
root_real at run time is at least
as great as that of any other floating point type defined by a
floating_point_definition,
and its safe range includes that of any such floating point type with
the same Digits attribute. On some machines, there might be real types
with less accuracy but a wider range, and hence run-time calculations
with
root_real might not be able to accommodate all values that
can be represented at run time in such floating point or fixed point
types.
Implementation Permissions
{
AI95-00114-01}
[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).]
{nonstandard real
type} 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.]
Implementation defined: Any nonstandard
real types and the operators defined for them.
34 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.
Wording Changes from Ada 83
All discussion of model numbers, safe ranges,
and machine numbers is moved to
3.5.7,
3.5.8,
and
G.2. Values of a fixed point type are now
described as being multiples of the
small of the fixed point type,
and we have no need for model numbers, safe ranges, etc. for fixed point
types.