22.800000 and a 1 on the end!!??

Qwerty Maniac qwertymaniac at gmail.com
Sun May 25 16:26:01 EDT 2008


Like what others said, use the Decimal class to avoid this.

from decimal import Decimal
x=Decimal(5)
x/=2
x*=Decimal("11.4")
print x
# 28.50

On Mon, May 26, 2008 at 1:28 AM, <notnorwegian at yahoo.se> wrote:

> >>> x = 5
> >>> x /= 2
> >>> x
> 2
> >>> x *=11.4
> >>> x
> 22.800000000000001
>
> ok where does the 1 in the come from?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Harsh J
www.harshj.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080526/159b4b22/attachment-0001.html>


More information about the Python-list mailing list