Re: Gentler Decimal Floating-Point



Mike Cowlishaw wrote:

quoting me:
Decimal floating point uses a radix of 10. Could it be possible to
effectively change the radix of a decimal floating point
representation while still keeping the number in a decimal format?

See also:

FOCUS Microcomputer Number System, Albert D. Edgar and Samuel C. Lee,
Communications of the ACM Vol. 22 #3, pp166-177, ACM Press, March 1979.

As it happens, on my page at

http://www.quadibloc.com/comp/cp0202.htm

under the heading "Logarithms all the time", I briefly mention their
paper.

While one could conceive of a relation of sorts between my proposal
and logarithms, I do wish to hasten to point out that the connection
is quite limited.

The FOCUS number system was an attempt to allow microcomputers to
perform ariithmetic on limited-precision quantities more rapidly by
storing the *logarithms* of those numbers in memory, rather than the
numbers themselves. This had been proposed from time to time, and was
also done on the early Wang calculators.

The benefit is that multiplication is now replaced by addition, and
division is replaced by subtraction, and addition and subtraction are
faster to perform in hardware than multiplication.

But how do you then perform addition of numbers so represented without
converting them back to conventional form? The paper on the FOCUS
number system presented an ingenious idea.

Given two numbers, a and b, which are to be added, we will assume,
without loss of generality, a to be the smaller of the two numbers.
(In the event that the first number considered is the larger, we may
assign it to b.)

a/b may be calculated by the use of division (which is subtraction, an
available operation). Let us call the result of this calculation r. A
single lookup table, for those values of r for which a+b will sensibly
differ from b, can contain (r+1)/r for each value of r.

Multiply b by ((r+1)/r), and you get a+b.

This is because (r+1)/r is ((a/b) + 1)/(a/b), which is the same as (a
+b)/b, of course.

So you have addition implemented as one division (subtraction), one
table look-up, and one multiplication (addition), which allows the
logarithmic representation of numbers to be made workable for all the
basic arithmetic operations.

This is interesting, and perhaps it could be extended to longer
floating-point precisions by using *interpolation* on a table of (r+1)/
r (physically realized as a table of log((r+1)/r), of course).

But what I am suggesting is not really related to this. Arithmetic in
the decimal representation of numbers I propose is still being carried
out in the conventional manner, addition as addition, multiplication
as multiplication - speeded up with Wallace tree circuits, perhaps,
but still requiring repeated addition.

Instead, my goal is considerably more modest.

In effect, my intent, by combining the first and last digits of a
decimal floating-point number's mantissa/coefficient/significand/
fraction into a single field is simply to replace a radix-10 numerical
representation to a mixed-radix representation using radices of 2,
2.5, and 2. The middle digits are shifted only when the exponent,
still indicating a power of 10, changes by one; the first and last
digits, sharing a four-bit field, move by smaller steps.

So when the first digit is 1, the last digit may be 0, 2, 4, 6, or 8.

When the first digit is 2, 3, or 4, the last digit may be 0 or 5.

When the first digit is 5, 6, 7, 8, or 9, the last digit can only be
0; that is, it is omitted.

So we basically divide the first and last digits into chunks of 1/3 of
a digit; the first digit may take 1/3, 2/3, or 3/3 of a digit, and the
last digit takes the other 2/3, 1/3, or 0/3 of a digit. The four-bit
field combines the first digit, the last digit, and, in effect, the
least significant portion of the exponent in thirds of a digit. All
this fits into a four-bit field because, in effect, the first bit of
the mantissa is hidden - just like in IEEE 754 (and PDP-11) binary
floating point!

The benefit of this is that one unit in the last digit of the mantissa
is now a more nearly constant fraction of the value of the mantissa as
a whole:

For example, assuming only three decimal digits in the middle of the
mantissa,

from
..10000 to
..19998

one unit in the last place, .00002, is .02% to .01%,

from
..20000 to
..49995

one unit in the last place, .00005, is .025% to .01%, and

from

..5000
..9999

one unit in the last place, .0001, is .02% to .01%.

So the unit in the last place, instead of varying by a factor of 10 as
a part of the number, varies at most by a factor of 2.5. This is
intended to give decimal floating point the same nice numerical
properties as radix-2 exponent binary floating point is said to have
as opposed to radix-8 and radix-16 exponent binary floating point.

Certainly, the increments used are suggested by the tick marks on a
slide rule, and a slide rule is logarithmic, but this system is really
not logarithmic in nature.

John Savard

.



Relevant Pages

  • Re: gfortran prints incorrect arithmetic results
    ... You cannot, unless you use higher precision. ... decimal digits from any floating point value. ... the floating point representation is not ...
    (comp.lang.fortran)
  • Re: This calculation is just wrong / computer cant count!
    ... If you use Newcomer's floating point explorer you will see in the bit ... (The full 64-bit representation of your number is 0x3FEAAAAAAAAAAAAB ... I only show the mantissa precision. ... if you want to compute floating point to 17 digits of ...
    (microsoft.public.vc.mfc)
  • Re: This calculation is just wrong / computer cant count!
    ... If you use Newcomer's floating point explorer you will see in the bit ... (The full 64-bit representation of your number is 0x3FEAAAAAAAAAAAAB ... if you want to compute floating point to 17 digits of ... precision, expect to encounter these kinds of errors in those last 2 ...
    (microsoft.public.vc.mfc)
  • Re: Rounding of the double
    ... When in doubt, trust the representation. ... digits precision", the first rule is that only the binary bits matter. ... The formal specification of floating point precision is usually expressed as ±1 LSB (Least ...
    (microsoft.public.vc.mfc)
  • Re: How do you keep track of what all the numbers mean?
    ... that if you develop a floating point representation of a system, ... but I would suspect that scaling constants is a main part of it. ... There will be an assumed scaling between the floating point ... will depend upon the input signal power. ...
    (comp.dsp)