Hi,
I am reading some values from a file and comparing them. Now there is a NaN value in the file which also passes through the if condition.
My program is something like this:
float j, k;
j = sqrt(-1); // to generate NaN
k = j;
if ( j < k || j > k )
printf("\n values are different");
else
printf("\n values are identical");
I am compiling this program using pgcc on Interix. I get the output “Values are different”. But if I use gcc instead of pgcc on interix I get the output values are identical. Also if I check the sign of j, k it is negative when compiled with pgcc and positive when compiled with gcc. I found this when I compared it if it is less than or greater than 0.
if (j < 0)
printf("\n Negative");
else
printf("\n Positive");
Please explain this behaviour.
Thankyou
Sudeep