This is an old copy of the Python FAQ. The information here may be outdated.

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:


CATEGORY: general


A Django site. rendered by a django application. hosted by webfaction.