about floating number

Travis Nixon tnixon at avalanchesoftware.com
Thu Oct 19 12:29:36 EDT 2000


That's because it's not possible to exactly represent 2.8 in binary floating
point.

In fact, I'm sort of impressed that you only lost .0000000000000002 in
precision.  When I try to represent 2.8 as a double in MS Devstudio, it
gives me 2.7999999523163, which is about 8 orders of magnitude less precise
than yours. :)

If you're worried about this loss of precision, do keep in mind that you're
talking about a loss of less than one quadrillionth(?) of a unit. :)

Basically, though, it's just a fact of life regarding floating point
numbers.  Not all numbers are exactly representable in a base 2 binary
format.

----- Original Message -----
From: "Graduate" <g8741082 at ccunix.ccu.edu.tw>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, October 19, 2000 1:28 AM
Subject: about floating number


> when I in python 2.0, I try to use floating number,
>  but I have a proplem like this...
>  >>> a = 2.8
>  >>> a
>  2.7999999999999998
>
>  why? or I forget some step??
>  I try this in Linux & windows...
>  thanks...
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list