[issue2653] string to float to int

Amaury Forgeot d'Arc report at bugs.python.org
Fri Apr 18 09:34:58 CEST 2008


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

Yes, and 
  >>> 1.005 * 1000
  1004.9999999999999

Please read 
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate

To perform exact base-10 calculation, you may use the Decimal module.
Or use round() instead of the int() truncation.

----------
nosy: +amaury.forgeotdarc
resolution:  -> invalid
status: open -> closed

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


More information about the Python-bugs-list mailing list