When the bounds in a type declaration are not model numbers AI-00469/04 1
89-06-16 ra WA
| !standard 03.05.07 (12) 89-06-16 AI-00469/04
!class ramification 87-02-18
| !status WG9-approved 89-06-16
!status ARG-approved 88-05-10 (reviewed)
!status panel/committee-approved (8-0-0) 87-02-18 (pending editorial review)
!status work-item 86-10-13
!status received 86-10-13
!references AI-00174, 83-00327
!topic When the bounds in a type declaration are not model numbers
!summary 87-06-22
For a type declaration having the form
type F is digits D range L .. R;
the values of L and R must belong to the range -F'SAFE_LARGE .. F'SAFE_LARGE.
!question 88-05-02
3.5.7(12) requires that
if a range L..R is supplied [in a floating point type
declaration], then both L and R must belong to the range of safe
numbers.
Since L and R are defined by model intervals and since only values belong to
ranges (see 3.5(3)), what does it mean for L and R to belong to the range of
safe numbers?
!response 88-03-15
The "range of safe numbers" is, in ordinary English, the range defined by the
smallest (most negative) safe number as the lower bound and the largest safe
number as the upper bound. 3.5(3) says:
[A] value V is said to belong to [a] range [L..R] if the
relations L <= V and V <= R are both TRUE.
Suppose a type definition is given as follows:
type F is digits D range L .. R;
Once a predefined base type has been selected for F, the range of safe
numbers for F will be -F'SAFE_LARGE .. F'SAFE_LARGE. L and R need not be
model or safe numbers and can have any real type, but L and R must be static.
The intent is to select F'BASE such that the computed values of L and R,
after conversion to type F'BASE, belong to the range -F'SAFE_LARGE .. F'SAFE_
LARGE.
One way to accomplish this is as follows. Compute a value for expression R
(and similarly for L) according to the accuracy rules of 4.5.7. The result
is some particular value, call it R1, of some real type TR (the type of
When the bounds in a type declaration are not model numbers AI-00469/04 2
89-06-16 ra WA
expression R), that belongs to some (not necessarily minimal) safe interval
SIR1. Although R1 could be any value of type TR belonging to SIR1, once R1
is computed, only that particular value need be considered.
Next, given R1 (and similarly L1), select a proposed predefined base type
FBT1 such that FBT1'DIGITS >= F'DIGITS and such that L1 and R1 could be in
the range -F'SAFE_LARGE .. F'SAFE_LARGE. Next, convert R1 (and L1) to type
FBT1. Call this value R2. Again, R2 may be any value in a safe interval
SIR2, but only the particular value R2 need be further considered. Since F'
SAFE_LARGE is a safe number, it will be converted exactly to type FBT1.
Next, check that -F'SAFE_LARGE <= R2 and R2 <= F'SAFE_LARGE (and similarly
for L2), using the relational operators for type FBT1. If all these
relations yield TRUE, then FBT1 is an acceptable base type for F. This will
usually be the situation. Otherwise, a larger (wider range) base type FBT2
must be proposed, and the steps involving FBT1 repeated using FBT2. If
iterating through successively larger predefined base types fails to find an
acceptable base type, then the type declaration for F can be rejected, even
though a different value for R1 within safe interval SIR1, or for R2 within
SIR2, might have succeeded.