When the float variable is not equal to itself

I was given this task on test tests. The question was that I was passed to float as a parameter and asked when the next code would be false.

bool result  = (floatValue == floatValue);

I could not think of an acceptable cause or situation where it would be false and still cannot. In the end, I replied that there would never be a case when this would be false. I wonder if anyone can give me an example (s) when this will be false

+4
source share
1 answer

floatValue == NaN

If floatValue is the result of a calculation that is not a number, for example 0/0.

+9
source

Source: https://habr.com/ru/post/1609882/


All Articles