Problem whit float precision, 1.6 Windows 98
Dan Schmidt
dfan at harmonixmusic.com
Wed Sep 13 12:52:00 EDT 2000
"Juan Huertas" <jhg at galdon.com> writes:
| Interactive windows:
|
| >>> a=12020.685
| >>> a
| 12020.684999999999
|
| This is a great problem for monetary treatment.
|
| Please aid.
>>> "%.3f" % a
'12020.685'
If you need to work with exact numbers, you should internally multiply
everything by 1000 and use ints. Floats can't represent numbers like
12020.685 exactly.
--
Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html
More information about the Python-list
mailing list