Why can 0.1 + 0.2 be awkward in JavaScript? The answer begins with the mantissa, also called the significand: the significant value scaled by a power of the radix. In decimal, 123.45 can be written as 12345 × 10⁻²; 12345 is the significand. Floating-point numbers use radix 2 instead. section 3.1.1
A JavaScript Number uses IEEE-754 Binary64: one sign bit, 11 exponent bits, and 52 stored significand bits. For the binary value shown by the encoding equation, those significand bits follow a leading 1; the exponent supplies the power of 2 that scales it. section 3.1.1
Table 3.3 Representing 0.1 and 0.2 as floating-point numbers
|
Value
|
Sign
|
Exponent
|
Significand
|
|
0.1
|
0
|
01111111011
|
1.1001100110011001100110011001100110011001100110011010
|
|
0.2
|
0
|
01111111100
|
1.1001100110011001100110011001100110011001100110011010
|
The encodings of 0.1 and 0.2 show their significand bit patterns and different exponents, making the binary representation concrete. section 3.1.1
The practical distinction is simple: the mantissa supplies significant bits, while the exponent sets their scale. Reading both is necessary to understand a floating-point value. section 3.1.1






