JavaScript · Middle · Question 73 of 75

How should money be stored to avoid 0.1 + 0.2 problems?

Explanation

Binary floating point can't represent most decimal fractions exactly. Integer cents (or BigInt) keep sums exact; Intl.NumberFormat formats them for users.

Further reading

Problem with a question

JavaScript · Middle · question 73

Test yourself

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

Take this quiz