JS Built-ins
NumberEPSILONintermediate

Number.EPSILON β€” floating point addition problem

πŸ“– Usage Example
// Use EPSILON to compare floats safely
0.1 + 0.2 === 0.3   // β†’ false (floating-point issue)
Math.abs(0.1 + 0.2 - 0.3) < Number.EPSILON   // β†’ true

Use Number.EPSILON as a tolerance threshold when comparing floating-point numbers that may differ by tiny rounding errors.

Floating Point Addition

In JavaScript, 0.1 + 0.2 !== 0.3 due to floating-point representation.

0.1 + 0.2 === 0.3  // β†’ false!
πŸ’‘ Hints (1)
  • β€’ Floating point arithmetic is not exact; `Number.EPSILON` helps you define a tolerance.