Answer the question
In order to leave comments, you need to log in
Is it correct to compare a real number with zero?
In fact, I know how to correctly compare real numbers, but I don’t understand how the following code will behave:
float x = 0.0;
...
if ( x == 0.0 ) { ... }
Answer the question
In order to leave comments, you need to log in
If it is the constant zero that is assigned, and not the result of any calculation, then comparison with zero is safe.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question