Universal real operands with fixed point * and 86-12-01 AI-00376/04 1
| !standard 04.05.05 (10) 86-12-01 AI-00376/04
| !class ramification 85-08-22
| !status approved by WG9/AJPO 86-11-26
| !status approved by Director, AJPO 86-11-26
| !status approved by WG9/Ada Board 86-11-18
!status committee-approved (9-0-0) 85-11-20
!status work-item 85-10-31
!status received 85-08-22
!reference AI-00020, 83-00603
!topic Universal real operands with fixed point * and /
!summary 85-10-31
An expression having type universal_real is not allowed as an operand of a
fixed point multiplication or division operation. The possibility of
adopting a more liberal rule in a future version of the language will be
studied.
This commentary extends the conclusions of AI-0020 to cover all expressions
of type universal_real, not just those having the form of a real literal.
!question 85-10-31
Multiplication and division are allowed for operands of any fixed point type,
but the Standard appears to forbid fixed point multiplications and divisions
involving expressions having the type universal_real. Is this an oversight?
!response 85-10-31
The expression
Fixed_Point_Type (V1 * UR)
is illegal when V1 has a fixed point type and UR has type universal_real
(e.g., if UR is a named number) because * is not defined for one operand of
type universal real and the other operand of some fixed point type; hence,
the expression can only be legal if the real literal can be converted
(implicitly) to a unique fixed point type [4.6(15)]. But there is no unique
fixed point type to which UR can be converted. (There is no unique fixed
point type since there are always at least two fixed point types whose scope
includes every compilation unit -- the type DURATION and the anonymous
predefined fixed point type specified in 3.5.9(7)). The same argument
applies to fixed point division.
It would be possible to extend the language so * and / were defined for
combinations of fixed point types and universal real values. However,
performing such arithmetic operations with the accuracy required by the
Standard is not straightforward. A literal such as 3.14 must be treated as
an exact quantity, i.e., as though its 'SMALL were 3.14. (Then 3.14 will be
represented exactly as a model number.) Consequently, to evaluate V1 * 3.14
correctly requires the same support from a compiler as that required when the
compiler has decided to support 'SMALL values that are not powers of 2.
Universal real operands with fixed point * and 86-12-01 AI-00376/04 2
Since an implementation does not have to support the representation clause
for 'SMALL (at least for values that are not powers of two; see 13.1(10)), it
would be inconsistent to require such support in order to process V1 * 3.14.
The possibility of removing this restriction in a future version of the
Standard will be studied, but the current Standard is unambiguous on this
point.
This discussion extends the discussion and conclusion of AI-00020 to include
all expressions having a universal_real type. AI-00020 covered just
expressions having the form of a real literal.