Floating-point arithmetic represents numbers with finite precision, allowing JavaScript to use one number type for integers, fractions, and very large or small values. JavaScript stores regular numbers as 64-bit IEEE 754 values, so some decimal fractions are approximations rather than exact values. section 2.2.1 section 2.3.1
The calculation that almost matches
The expression 0.1 + 0.2 === 0.3 returns false because 0.1 and 0.2 become rounded binary approximations before JavaScript adds them. For UI calculations such as spacing, animation timing, or alignment, compare values with a small tolerance: Math.abs((0.1 + 0.2) - 0.3) < Number.EPSILON. section 2.3 section 2.3.1
Precision becomes especially important when calculations drive interface behavior:
- Round values when animation timing, visual snapping, spacing, or alignment must settle on predictable results. section 2.3.2
- Format values for display with a specified number of decimal places instead of exposing internal approximations. section 2.3.2 section 2.9
- Check integer boundaries with Number.isSafeInteger(); values beyond Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER are not reliably precise. section 2.2.1
0.1 + 0.2 === 0.3
Run the equality test, then compare its false result with the EPSILON-based tolerance check to see how finite precision affects JavaScript calculations. section 2.3 section 2.3.1



















