# Version 1.2 of ais/ai-00203.txt

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

!standard 03.05.08 (02)          98-09-08 AI95-00203/01
!class binding interpretation 98-03-27
!status work item 98-09-08
!priority Medium
!difficulty Hard
!subject S'Digits when T'Machine_Radix is 10.
!summary 98-09-08
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 which 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
If Machine_Radix is 10 this becomes simply
d <= T'Model_Mantissa
so that S'Digits = T'Model_Mantissa.
!question 98-09-08
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?
!recommendation 98-09-08
(See Summary.)
!wording 98-09-08
!discussion 98-09-08
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 ARM (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.
!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