Dev & Computing · 浮点数(Floating Point) · Updated 2026-10-25
What Is Floating Point?
Definition
IEEE 754 double precision uses 64 bits (1 sign + 11 exponent + 52 mantissa) for ~15-17 significant decimal digits, but 0.1 is a repeating binary fraction (0.000110011…) truncated on store — hence 0.1+0.2 = 0.30000000000000004. This is shared behavior across IEEE 754 languages (Python, Java, JS, C). Three rules for exact work: store money as integer cents; compare with tolerance (|a−b|<1e-9, never ===); format for display via a decimal library (toFixed rounds and carries banker's-rounding risk).
Formula
value = (−1)^s × 1.m × 2^(e−1023); 0.1 repeats in binary
Worked Example
0.1+0.2 = 0.30000000000000004; summing 0.1 a thousand times yields 99.9999999999986, not 100.
Common Misconception
"toFixed(2) makes it exact" — toFixed itself mis-rounds boundary cases (1.005) due to binary representation. And "invisible error is fine" — ten thousand accumulations can put books off by a cent, and reconciliation explodes.
Matching Calculators
Related Terms
Keep Exploring
Browse the full glossary, or head back to the homepage for 1,435 free online calculators.
Back to glossary