Bit twiddling floating point numbers

Grant Edwards grante at visi.com
Wed Mar 5 15:59:23 EST 2008


On 2008-03-05, Jeff.Goldfinkle at gmail.com <Jeff.Goldfinkle at gmail.com> wrote:

> thanks for the reply but I'm still unsure as to how to
> continue. Using the bitwise operators will help me deal with
> integers but I really want to work with floats.

In your original post, you said that you've got the values as
integers.

> For instance - which bits do I twiddle to round my float to
> the nearest number of bits?

The format of a float (actually Python uses doubles) depends on
your platform, but in all likelihood it's the IEEE-754 64-bit
format.

googling for "IEEE-754 format" finds some good references:

 http://en.wikipedia.org/wiki/IEEE_floating-point_standard
 http://steve.hollasch.net/cgindex/coding/ieeefloat.html
 http://www.psc.edu/general/software/packages/ieee/ieee.html

-- 
Grant Edwards                   grante             Yow! Well, I'm INVISIBLE
                                  at               AGAIN ... I might as well
                               visi.com            pay a visit to the LADIES
                                                   ROOM ...



More information about the Python-list mailing list