Tag

decimal module

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Feb 25, 2025 · Fundamentals

Why Does 0.1 + 0.2 Not Equal 0.3 in Python? Understanding Floating‑Point Precision

Python’s unexpected 0.1 + 0.2 = 0.30000000000000004 result stems from binary floating‑point representation limits defined by the IEEE 754 standard, and the article explains this issue, rounding modes, and practical solutions such as the decimal module, fractions, math.isclose, and high‑precision NumPy types.

Floating PointIEEE 754NumPy
0 likes · 9 min read
Why Does 0.1 + 0.2 Not Equal 0.3 in Python? Understanding Floating‑Point Precision