We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

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