"Small" should be a power of two TIMES THE RAN 87-02-10 AI-00519/00 1
!standard 03.05.09 (05) 87-02-10 AI-00519/00
!class study 87-02-10 (provisional classification)
!status received 87-02-10
!topic "Small" should be a power of two TIMES THE RANGE
!summary 87-02-10
!question 87-02-10
!recommendation 87-02-10
!wording 87-02-10
!discussion 87-02-10
!appendix 87-02-10
*****************************************************************************
!section 03.05.09 (05) Terry Froggatt 86-12-07 83-00886
!version 1983
!topic "Small" should be a power of two TIMES THE RANGE
Ada's default power of two scaling of "small" was a mistake.
Power of two scaling is more of a distraction than an abstraction:
it seems to be of very limited use. For serious embedded applications,
range-related scalings are necessary: and in their absence programmers
will sensibly use pure fractions.
With range-related scalings, we get maximum accuracy, we get range
checks at minimum cost, and we avoid spurious scaling operations.
Thus we get a cheap floating point that is both cheaper and better
than with power of two smalls. And we get the scaled fractions of
classical fixed-point working for use where this is appropriate
whether or not we have floating hardware, such as angles with
natural scalings and sensors with given scalings.
If there is ever a major revision of Ada, the right solution would
be to make range-related scalings the default. There would then be no
need for small representation clauses at all. (Anyone then wanting the
current default scaling or a true delta-related scaling could achieve
this by declaring a type with an appropriately expanded range followed
by a subtype of it with the required range: no extra facility is needed).
Implementation of range-related scaling is in itself straighforward,
but for Ada's counter-productive accuracy requirements.
These matters are discussed in some more detail in my paper,
"Fixed-Point Conversion, Multiplication, & Division, in Ada(R)",
to appear shortly in Ada Letters.