Declaring a fixed point type that occupies one 87-08-06 AI-00147/05 1
| !standard 03.05.09 (18) 87-08-06 AI-00147/05
| !class ramification 84-01-10
| !status approved by WG9/AJPO 87-07-30
| !status approved by Director, AJPO 87-07-30
| !status approved by Ada Board 87-07-30
!status approved by WG9 87-05-29
!status panel/committee-approved 87-01-19 (reviewed)
!status panel/committee-approved (6-0-0) 86-11-14 (pending editorial review)
!status work-item 86-10-05
!status received 84-01-10
!references 83-00232
!topic Declaring a fixed point type that occupies one word
!summary 86-10-05
A fixed point type that occupies a full word can be declared as:
DEL : constant := 1.0/2**(WORD_LENGTH - 1);
type FRACTION is delta DEL range -1.0 .. 1.0 - DEL;
!question 86-10-05
3.5.9(18) gives the following declarations as the way to declare a fixed
point type that fully occupies one word:
DEL : constant := 1.0/2**(WORD_LENGTH - 1);
type FRACTION is delta DEL range -1.0 .. 1.0 - DEL;
It does not seem that this type declaration is correct, since the base type
must be chosen so -1.0 can be represented as a model number. Shouldn't the
declaration be as follows?
type FRACTION is delta DEL range -1.0 + DEL .. 1.0 - DEL;
!response 87-06-04
The example as written is correct. 3.5.9(6) requires that the mantissa
length be chosen
as the smallest integer number for which each bound of the
specified range is either a model number or lies at most SMALL
distant from a model number.
For the type FRACTION, SMALL is equal to DEL. The smallest model number for
type FRACTION is -1.0 + DEL, which does lie at most SMALL from the lower
bound, -1.0, when the mantissa length is WORD_LENGTH - 1. (Note that -1.0
itself is not a model number.)