[issue2140] calculation bug in long() function

Facundo Batista report at bugs.python.org
Mon Feb 18 13:25:05 CET 2008


Facundo Batista added the comment:

In short: 

>>> long(100 * 146.95)
14694L

This is NOT a bug, but a behaviour of binary floating point:

>>> 146.95
146.94999999999999

In binary you can not express this number exactly.

>>> 146.95 * 100
14694.999999999998

When you long() that, you truncate the number, so it goes to 14694.

Please address further discussion through python-list.

Thanks!

----------
nosy: +facundobatista
resolution:  -> invalid
status: open -> closed

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2140>
__________________________________


More information about the Python-bugs-list mailing list