Search code examples
javascriptcomparisonoperatorsstrict

Why does Javasript's strict comparison act the way it does?


Possible Duplicate:
Is JavaScript’s math broken?

If the main difference between Javascript's "strict comparison" operators and the traditional ones is type coercion, why does

0.1+0.2===0.3;

return false?


Solution

  • In Firefox and Chrome, 0.1 + 0.2 is 0.30000000000000004, which is not equal to 0.3. This is presumably caused by it not being possible to represent 0.1 exactly as a floating point number.