Floating numbers
Grant Edwards
invalid at invalid.invalid
Thu Aug 12 17:24:14 EDT 2010
On 2010-08-12, Grant Edwards <invalid at invalid.invalid> wrote:
> 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
Here is a gentler intro:
http://pyfaq.infogami.com/why-are-floating-point-calculations-so-inaccurate
--
Grant Edwards grant.b.edwards Yow! If I felt any more
at SOPHISTICATED I would DIE
gmail.com of EMBARRASSMENT!
More information about the Python-list
mailing list