Answer the question
In order to leave comments, you need to log in
In a java script, a false condition is sometimes met, how can this be?
Sometimes there are such incidents:
The condition should not work, but it works, while the execution of the body of the condition skips one command.
It seems that the parser does not see curly braces after the condition, so one command is skipped - the condition works correctly for the first command after the condition
Maybe someone has come across such cases? How to fight?
Answer the question
In order to leave comments, you need to log in
This may occur due to the fact that decimal floating point numbers under the hood still have a binary representation, and therefore the number may not be 20.0, but, for example, 20.000000001, and then 20.000000001 - 20 will be 0.000000001, which is greater than zero .
Operate with whole numbers in such cases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question