correct, it is a floating point issue regardless of language.. it's
not just Python. you cannot accurately represent repeating fractions
with binary digits (bits). more info specific to Python here:
http://docs.python.org/tutorial/floatingpoint.html

also, keep in mind that '%f' is not a rounding operation... it just
converts floats to strings. if you want to round, you need to use both
string formatting as well as the round() built-in function.

finally, +1 on using decimal.Decimal as necessary comfortwise.

cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to