Float compression [Re: floating point math results question]
Peter Hansen
peter at engcorp.com
Sat Jan 26 20:31:55 EST 2002
François Pinard wrote:
>
> [Peter Hansen]
> > [Phil Hunt]
> > > [Courageous]
>
> > > >Second, as an academic exercise, you may now attempt to represent the
> > > >number 0.8 [that is: 4.0/5.0] ]as a 32 bit binary value.
>
> > > I can do it in 24 binary bits: 00110000 00101110 00111000
>
> > Naw, that was 26 ASCII characters. The original "0.8" is 24 bits.
> > I can do it in 16 bits: ".8" !! Fewer if you are willing to drop the
> > leading binary zeros. <grin>
>
> I guess that it is an interesting exercise, trying to represent an arbitrary
> float number within a given tolerance, with a small number of bits.
I think you have to take into account dynamic range. If I said I want
to represent 0.8 accurately "in binary", with a dynamic range from 0.0 to
1.0, I could just use four bits (fixed point). I'd even have five values
left over for representing special cases, if I were writing this in
assembly on a machine with 128 bytes of memory, twenty years ago. :-)
Actually, I guess we're talking about two different things, since you
mentioned "floats" and I mentioned "fixeds".
-Peter
More information about the Python-list
mailing list