JavaScript · Junior · Question 11 of 75

What does 0.1 + 0.2 === 0.3 evaluate to?

Explanation

Numbers are stored in binary IEEE-754 format, and 0.1 and 0.2 can't be represented exactly - the sum is 0.30000000000000004. Compare numbers with a tolerance (Math.abs(a - b) < Number.EPSILON), and handle money as integer cents.

Further reading

Problem with a question

JavaScript · Junior · question 11

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz