Bit twiddling floating point numbers

Grant Edwards grante at
Wed Mar 5 21:59:23 CET 2008

On 2008-03-05, Jeff.Goldfinkle at <Jeff.Goldfinkle at> 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

> 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

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

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

More information about the Python-list mailing list