Floating-point numbers in JS, Python, C, etc. follow IEEE 754. Many decimals cannot be represented exactly in binary floating point — same as 1/3 in decimal.

What to do in code

For comparisons, use an epsilon: Math.abs(a - b) < 1e-9 (scale epsilon to your domain).

For money, prefer integer cents or a decimal library — not raw double for accumulation.

Display

Formatting with fixed decimals hides noise but doesn’t fix underlying errors — know what you’re rounding.