A fixed point type declaration cannot raise an exception AI00144/11 1
890307 BI WJ
 !standard 03.05.09 (09) 890307 AI00144/11
!class binding interpretation 840110
!status approved by WG9/AJPO 870730 (corrected in accordance with AI00471)
!status approved by WG9/AJPO 860722
!status approved by Director, AJPO 860722
!status approved by WG9/Ada Board 860722
!status approved by Ada Board 860722
!status approved by WG9 860509
!status committeeapproved (800) 860220
!status workitem 851118
!status returned to committed by WG9 851118
!status committeeapproved (801) 850904
!status workitem 840612
!status received 840110
!references AI00143, AI00471, 8300235, 8300822
!topic A fixed point type declaration cannot raise an exception
!summary 870909
A fixed point type declaration cannot raise an exception. Declarations such
as:
type F is delta 2.0**(15) range 1.0 .. 1.0;
are legal even if F'SIZE is equal to 16 so 1.0 is not a representable value.
!question 870909
The equivalence stated in 3.5.9(9) suggests that the declaration:
type F is delta 2.0**(15) range 1.0 .. 1.0;
will raise NUMERIC_ERROR if the implementation chooses a predefined type such
that F'SIZE = 16, i.e., such that 1.0 is not a representable value. Is this
correct, or is the equivalence only for expository purposes, implying that
NUMERIC_ERROR cannot be raised?
!recommendation 870909
A fixed point type declaration cannot raise an exception. Declarations such
as:
type F is delta 2.0**(15) range 1.0 .. 1.0;
are legal even if F'SIZE is equal to 16.
!discussion 870909
The declaration:
type F is delta 2.0**(15) range 1.0 .. 1.0;
is stated to be equivalent to:
A fixed point type declaration cannot raise an exception AI00144/11 2
890307 BI WJ
type %FP is new %PDF;
subtype F is %FP range %FP(1.0) .. %FP(1.0);
An implementation is allowed to choose the predefined type %PDF such that all
and only the model numbers of F are representable, e.g., %PDF might occupy
just 16 bits (see AI00143). In such a case, the upper bound of %FP, the
base type of F, is 1.02.0**(15), i.e., the value 1.0 lies just outside the
range of the base type. A conversion of a value that lies outside the target
type's base type is allowed to raise NUMERIC_ERROR [4.5.7(7)], so it would
seem that the conversion, %FP(1.0) is allowed (or required) to raise NUMERIC_
ERROR. However, it was intended that declarations like the one given be
accepted for a base type that occupies just 16 bits. It was intended to
allow programmers to write:
type F is delta 2.0**(15) range 1.0 .. 1.0;
rather than requiring programmers to write:
type F is delta 2.0**(15) range 1.0 .. 1.02**(15);
In short, the declaration given in the question is legal and neither NUMERIC_
ERROR nor any other exception can be raised by such a declaration. (Of
course, even if the type declaration is accepted, NUMERIC_ERROR could be
raised for F'(1.0).)
 !appendix 890123

 *****************************************************************************

 !section 03.05.09 (09) Mike Woodger 890123 8301258
 !version 1983
 !topic Further correction to AI00144

 AI00471 corrected AI00144 by replacing 2**(15) in the deltas of examples
 with 2.0**(15). However, the corrected declaration in the discussion reads:

 type F is delta 2.0**(15) range 1.0 .. 1.02**(15);

 This is still incorrect since the final 2**(15) should read 2.0**(15).
