1.00000100-0.00000100 results in 0.9999999999999999.
Why does this happen? How to get correct result?
It happens because of IEEE-754, nothing specific to JS. There's no way to get the math exact, but there is a way (covered in the Types & Grammar book) to use what's called the machine epsilon to check that the number you're comparing to is "close enough" to the number that it's considered within this margin of floating point error.
@getify Thanks for your response.
Most helpful comment
It happens because of IEEE-754, nothing specific to JS. There's no way to get the math exact, but there is a way (covered in the Types & Grammar book) to use what's called the machine epsilon to check that the number you're comparing to is "close enough" to the number that it's considered within this margin of floating point error.