Version 1.11 of ais/ai-00203.txt

Unformatted version of ais/ai-00203.txt version 1.11
Other versions for file ais/ai-00203.txt

!standard 03.05.08 (02)          99-10-06 AI95-00203/04
!class binding interpretation 98-03-27
!status Corrigendum 2000 99-07-27
!status WG9 approved 99-06-12
!status ARG approved 98-10-08 (6-0-1)
!status work item 98-09-08
!status received 98-03-27
!priority Medium
!difficulty Hard
!qualifier Error
!subject S'Digits when T'Machine_Radix is 10
!summary
The relationship between S'Digits and T'Model_Mantissa given in 3.5.8(2) states that S'Digits is the largest value of d for which
ceiling(d * log(10) / log(T'Machine_Radix)) + 1 <= T'Model_Mantissa
This allows for a "guard digit" which is necessary to take care of extreme circumstances that arise if the Machine_Radix is not decimal (as is usually the case).
However, this guard digit is unnecessary if Machine_Radix is 10 or a power of 10 and in such a case the relationship should read
ceiling(d * log(10) / log(T'Machine_Radix)) <= T'Model_Mantissa
If Machine_Radix is 10 this becomes simply
d <= T'Model_Mantissa
so that S'Digits = T'Model_Mantissa.
!question
The relationship given in 3.5.8(2) in the case of T'Machine_Radix = 10 implies that S'Digits + 1 = T'Model_Mantissa in such a case. Is this correct? (No.)
!recommendation
(See summary.)
!wording
(See summary.)
!discussion
This question echoes back to a change made between 1980 preliminary Ada and the 1983 standard which is worth explaining as background.
In Ada 83, the user specified a number D of decimal digits and the implementation then provided model numbers using B binary digits. Intuitively one might expect to need log 10 / log 2 (3.3219...) binary digits for every decimal digit (with appropriate rounding up). The 1980 edition of the Ada Reference Manual (3.5.7 third paragraph) says
(B is the next integer above D*ln(10) / ln(2)).
So 1 decimal digit might be expected to be equivalent to 4 binary digits, 2 decimal digits equivalent to 7 binary digits and so on. But this is not enough. Four binary digits give a relative precision of between 1 in 8 and 1 in 16 whereas one decimal digit requests a maximum precision of 1 in 10. Thus there are places where the model numbers for B = 4 are slightly too far apart.
For example the decimal model numbers around 10000 for D = 1 are
8000 9000 10000 20000
whereas the binary model numbers for B = 4 are
7680 8192 9216 10240
and 8192 and 9216 are more than 1000 apart.
This surprising behaviour resulted in the addition of one to the formula so that 3.5.7(6) of Ada 83 concludes
(The number B is the integer next above (D*log(10) / log(2)) + 1.)
In Ada 95 this formula has been generalized to use T'Machine_Radix rather than 2. However, the special case where Machine_Radix is 10 (or indeed a power of 10) has been overlooked since then no anomalous situations can arise and the "guard digit" is not required.
The formula should therefore be adjusted accordingly.
Note the peculiar phenomenon that more digits may be required for a hexadecimal machine than a decimal machine. Thus one decimal digit requires 2 hexadecimal digits.
!corrigendum 3.05.08(2)
Replace the paragraph:
S'Digits
S'Digits denotes the requested decimal precision for the subtype S. The value of this attribute is of the type universal_integer. The requested decimal precision of the base subtype of a floating point type T is defined to be the largest value of d for which ceiling(d * log(10) / log(T'Machine_Radix)) + 1 <= T'Model_Mantissa.
by:
S'Digits
S'Digits denotes the requested decimal precision for the subtype S. The value of this attribute is of the type universal_integer. The requested decimal precision of the base subtype of a floating point type T is defined to be the largest value of d for which
ceiling(d * log(10) / log(T'Machine_Radix)) + g <= T'Model_Mantissa
where g is 0 if Machine_Radix is a positive power of 10 and 1 otherwise.
!ACATS test
Create a C-Test to check that if Machine_Radix is 10, then S'Digits = S'Model_Mantissa. (No Test, 3-4-1, ARG Letter Ballot, February 2001).
This change applies only a machine for which supports Machine_Radix = 10 for (some) float types, which is rare. Thus, an ACATS test has little value.
!appendix

!section 3.5.8(2)
!subject T'Model_Mantissa( if T'Machine_Radix is not 10, and
T'Model_Mantissa otherwise).
!reference RM95-3.5.8(2)
!from Samuel Figueroa 98-03-06
!keywords floating point digits attribute
!reference 1998-15821.a Samuel A. Figueroa 1998-3-6>>
!discussion
The mathematical expression that appears in the given paragraph simplifies
to "d+1 <= T'Model_Mantissa" when T'Machine_Radix is 10.  This doesn't seem
to be what was intended.  Rather, it would appear that the given expression
ought to simplify to "d = T'Model_Mantissa" when T'Machine_Radix is 10.

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


Questions? Ask the ACAA Technical Agent