Not A Number in IEEE Math

dougp at voodoo.ucsb.edu dougp at voodoo.ucsb.edu
Thu Feb 22 16:23:00 AEST 1990


-Message-Text-Follows-
In article <10515 at alice.UUCP>, ark at alice.UUCP (Andrew Koenig) writes...
>	0.0 * infinity = NaN (+ or - infinity -- I think it's implementation
>		defined whether or not NaN has a sign)
>	0.0 * NaN = NaN (as mentioned before)
>	0.0 * anything else = 0.0
> 
>	NaN / NaN = NaN (as mentioned before)
> 
>	infinity / infinity = NaN
>	infinity / NaN = Nan (as mentioned before)
>	infinity / anything else = infinity

Does this mean that compilers arn't alowed to optimize code?

Suppose someone writes:

double a,b;
a=NaN; /* who cares how*/
b=NaN;

a/a==1 /*can the compiler optomize this to TRUE ?*/
a/b!=1 /*this should work out to TRUE*/
0*a    /*can the compiler optomize this to 0? */

In most cases you never run into NaNs, I think I would prefer to
have the compiler optomize a/a to 1 and 0*a to zero.



More information about the Comp.lang.c mailing list