1
votes

Given the following:

.1 + .2 === .3 // false
1 * .3 === .3 // true

...the former does not result in 0.3 because one or more of the operands cannot be exactly represented in IEEE 754 double-precision floating point, so the result is almost but not quite 0.3.

Why does the latter return true. Is it because 0.3 happens to be exactly representable in IEEE 754 double-precision floating point?

1

1 Answers

1
votes

0.3 is not exactly representable, but 1.0 is. Multiplication of any number by 1, under IEEE round-to-nearest rules, must return the original value, which is equal to itself.