Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!peregrine!ccicpg!cci632!rit!tropix!ur-valhalla!uhura.cc.rochester.edu!rochester!rutgers!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.unix.wizards Subject: Re: what does NaN mean out of printf? Message-ID: <9639@alice.UUCP> Date: 15 Aug 89 14:18:06 GMT References: <20283@adm.BRL.MIL> <3876@phri.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 35 In article <3876@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes: > In article <20283@adm.BRL.MIL> Leisner.Henr@xerox.com (Marty) writes: > > What does NaN mean out of printf? > > You're on a machine which supports IEEE-754 arithmetic (for > example, a Sun, but there are many, many modern machines which fit this > description). NaN means Not A Number. NaN is the result of some illegal > arithmetic operation (division by zero, square root of a negative number, > etc). You're almost right. IEEE-754 defines two different kinds of exceptional values: infinity and NaN. Infinity has a sign and obeys several sensible rules. For example: +inf + +inf = +inf -inf + -inf = -inf - (+inf) = -inf - (-inf) = +inf +1 / +0 = +inf [with a possible trap] +1 / +inf = +0 [no trap] +1 / -0 = -inf [with a possible trap] and so on. However, 0 / 0 = NaN +inf + -inf = NaN and so on. NaN is extremely infectious: just about any operation on a Nan gives Nan as a result. -- --Andrew Koenig ark@europa.att.com