Why does Javasript's strict comparison act the way it does? [duplicate]
Possible Duplicate:
Is JavaScript’s math broken?
If the main difference between Javascript's "strict comparison" operators and the traditional ones is type coercion开发者_StackOverflow中文版, why does
0.1+0.2===0.3;
return false?
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.
because 0.1 is tricky
it's irrational recurring in binary (see comments)
EDIT
actually I'm winging it here, I don't know that for sure. Is there a Math.boffin out there who can disprove or provide a proof?
would be very interesting
精彩评论