Is 0.05 equal to 0
Is 0.00 equal to 0
I use parseinit. . . Something went wrong
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
Just use it===and it’ll be fine
0.000 === 0 // true 0.08 === 0 // false
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(a) < 0.0000001
Math.abs(0.1 + 0.2 - 0.3) < 0.0000001 // true 0.1 + 0.2 - 0.3 === 0 // false
parseint is converted to plastic. Think about it, what is 0.05 converted to plastic?
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
Just use it
===
and it’ll be fineYou have to pay attention to the error in decimals. It is best to provide an accuracy judgment, such as
Math.abs(a) < 0.0000001
parseint is converted to plastic. Think about it, what is 0.05 converted to plastic?