Floating-Point Number
noun
say it: “FLOH-ting POYNT NUM-ber” /ˈfloʊtɪŋ pɔɪnt ˈnʌmbər/
A number with a decimal point, stored the way computers store decimals: most are kept as a very close guess, so 0.1 + 0.2 shows 0.30000000000000004.
What is Floating-Point Number in JavaScript?
Floating-Point Number — The way computers store numbers with decimals. Every JavaScript number is floating-point, and most decimals can only be stored very close to their value, so 0.1 + 0.2 isn't exactly 0.3. For money, round to cents before you show or compare a total.
console.log(0.1 + 0.2); // 0.30000000000000004
console.log((0.1 + 0.2).toFixed(2)); // 0.30
In a sentence
- “My receipt showed 0.30000000000000004 because a floating-point number can't hold 0.1 exactly.”
Level: Apprentice · More JavaScript terms at this level
Updated