Why am I getting strange results with simple arithmetic operations?

Python (like most programming languages but unlike many calculators) uses binary floating point numbers. Floating point numbers are fast and work well with modern computer architecture, but are subject to representation errors when converting between the internal binary format, and decimal numbers. Your strange results are probably a result of these representation errors. For more explanation, see:

why-are-floating-point-calculations-so-inaccurate

CATEGORY: general

 

A Django site. this page was rendered by a django application in 0.01s 2008-11-21 14:25:06.975851. hosted by webfaction.