This would be good as an interview question on C for those guys working with computations.
You have some code:
if (tmp != tmp)
{
printf("it happened!");
}
You are running this application with tmp to be any of built-in types with no overloaded members (plain C).
Is there possibility that you would get “it happened!” printed out
and what should be the type of tmp in order to get this behaviour?
Correct answer: tmp should be float since when float value is NaN the != comparison would be true.
This is by IEEE 754 standard which defines NaN values as a such that != comparisons involving them are always true.