Skip to content
Justice Tech School

Number Limits and Precision

MAX_SAFE_INTEGER is 2^53 - 1. Floating point errors such as 0.1 + 0.2 are normal. Use integers for money or BigInt for huge values and compare with a tolerance.

Example
console.log(Number.MAX_SAFE_INTEGER, Number.EPSILON > 0);
console.log(0.1 + 0.2, Math.abs(0.1 + 0.2 - 0.3) < Number.EPSILON);
console.log(Infinity, -Infinity, 1 / 0);

Exercise

Safe integer limit.

Number.MAX_SAFE

Quiz Test

Why is 0.1 + 0.2 not 0.3?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.