Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: Not A Number in IEEE Math Keywords: IEEE floating point Message-ID: <10515@alice.UUCP> Date: 21 Feb 90 18:07:26 GMT References: <44@newave.UUCP> <14266@s.ms.uky.edu> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 31 In article <14266@s.ms.uky.edu>, simon@ms.uky.edu (G. Simon Gales) writes: > I think that that behavior is correct. > 0.0 * (anything) = 0.0 > and > NaN / NaN = 1.0 Sorry, but that's not what IEEE says. NaN is infinitely infectious. That is: any operation that gives a floating point result is supposed to return NaN if any of its operands is NaN. Relational operators all return `false' if either operand is NaN. Thus (x == x) is false if and only if x is NaN (unless, of course, your implementation is broken). Incidentally, 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 -- --Andrew Koenig ark@europa.att.com