Floating numbers

Grant Edwards invalid at invalid.invalid
Thu Aug 12 17:20:18 EDT 2010


On 2010-08-12, Bradley Hintze <bradley.h at aggiemail.usu.edu> wrote:

> Is there a way I can keep my floating point number as I typed it?

No.

> For example, I want 34.52 to be 34.52 and NOT 34.5200000002.

You can't represent 34.52 using base-2 IEEE floating point (the HW
floating point format used by pretty much all modern computers).
34.5200000002 is as close as you can get.

When you enter a base-10 floating-point number, the computer will use
the closest base-2 IEEE floating point number.

Here are the nitty-gritty details:

  http://docs.sun.com/source/806-3568/ncg_goldberg.html

Can you explain what your actual problem is?
  
-- 
Grant Edwards               grant.b.edwards        Yow! I'm imagining a surfer
                                  at               van filled with soy sauce!
                              gmail.com            



More information about the Python-list mailing list