Is 0.05 equal to 0
Is 0.00 equal to 0
I use parseinit. . . Something went wrong
PHP中文网2017-05-16 13:08:55
JavaScript does not strictly distinguish between decimals and integers, so you can directly determine whether they are equal, but it is best to use ===
而不是==
. Three equal signs are strictly equal. You can search on Baidu for specific differences
......
0.000 is of course equal to 0
PHP中文网2017-05-16 13:08:55
Just use it===
and it’ll be fine
0.000 === 0 // true
0.08 === 0 // false
PHP中文网2017-05-16 13:08:55
You have to pay attention to the error in decimals. It is best to provide an accuracy judgment, such as Math.abs(a) < 0.0000001
Math.abs(0.1 + 0.2 - 0.3) < 0.0000001 // true
0.1 + 0.2 - 0.3 === 0 // false
怪我咯2017-05-16 13:08:55
parseint is converted to plastic. Think about it, what is 0.05 converted to plastic?