What is the output of console.log(0.1 + 0.2 === 0.3)?

The story behind the answer

The output of console.log(0.1 + 0.2 === 0.3) is false.

JavaScript uses IEEE 754 binary floating-point numbers for its ordinary Number type. Many decimal fractions, including 0.1, 0.2, and 0.3, cannot be represented exactly in that binary format. The stored approximations of 0.1 and 0.2 add up to a value slightly greater than the approximation of 0.3, so strict equality fails.

This does not mean JavaScript arithmetic is randomly inaccurate: the result is deterministic and follows the IEEE 754 rules. A common solution for decimal calculations is to compare with a tolerance, such as Math.abs(a - b) < Number.EPSILON, or to store monetary amounts as integer cents. Number.EPSILON is the gap between 1 and the next representable Number value.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: