# [Cryptography] floating point

Ray Dillinger bear at sonic.net
Sat Dec 27 15:06:43 EST 2014

```
On 12/27/2014 05:54 AM, Jerry Leichter wrote:

> *There is no such thing as a mathematically reasonable fix-precision
> floating point model*.  The floats are not the rationals, and they
> are certainly not the reals.  Fixed-length integers aren't the
> integers either, but at least if properly designed they match the
> integers mod some value - though those aren't ordered, which leads to
> all kinds of traps for the unwary when "overflows" occur.  But floats
> don't really correspond to any well-understood, pre-existing
> mathematical model.

The IEEE floats are, mathematically speaking, are a set of
numeric values which approximate (though not very closely)
a logarithmic distribution.

This has always annoyed me somewhat.  If you're going to
approximate a logarithmic distribution, why not just make it
BE a logarithmic distribution?  Define your numeric value as
the result of raising some root to the power of the bit
representation, and you get a logarithmic distribution that
minimizes relative error better than the system IEEE is using
now.  Further, you get efficient and accurate(!) FP
multiplication and division using the same hardware you use

Of course you'd still have inaccurate addition and subtraction,
but heck, you've got that now.  You could at least get
multiplication and subtraction right, which is better than
IEEE does.

You still need an analogue of "denormalized" floats right around
zero because it breaks down there for the same reasons the IEEE
mantissa+exponent system does - but you need fixedpoint
representation anyway! You've got to have it for things like
modeling software and accounting, etc. where you're trying to
minimize or eliminate absolute error rather than relative error,
so using it for numbers near zero doesn't really increase
overall requirements.

Bear

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://www.metzdowd.com/pipermail/cryptography/attachments/20141227/6fe5066b/attachment.sig>
```