Leisner.Henr@xerox.com (Marty) (07/18/89)
What does NaN mean out of printf? (I assume it's some sorta float point error). I haven't ever seen it documented anywhere. marty ARPA: leisner.henr@xerox.com GV: leisner.henr NS: leisner:wbst139:xerox UUCP: hplabs!arisia!leisner
bobmon@iuvax.cs.indiana.edu (RAMontante) (07/19/89)
NaN == Not a Number i.e., not a legitimate floating-point value. I'm reasonably certain that this is defined by the IEEE floating-point format standard. -- the sorcerer's apprentice
roy@phri.UUCP (Roy Smith) (07/19/89)
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). -- Roy Smith, Public Health Research Institute 455 First Avenue, New York, NY 10016 {att,philabs,cmcl2,rutgers,hombre}!phri!roy -or- roy@alanine.phri.nyu.edu "The connector is the network"
gwyn@smoke.BRL.MIL (Doug Gwyn) (07/19/89)
In article <20283@adm.BRL.MIL> Leisner.Henr@xerox.com (Marty) writes: >What does NaN mean out of printf? Please direct C language questions to the C newsgroup, not a UNIX group. NaN stands for "Not a Number". In IEEE Std 754/854 floating-point arithmetic, there are a set of bit combinations reserved for representing non-numbers, as well as values for positive and negative infinity. If you haven't arranged your computation correctly, you can easily find one of these odd creatures lurking in a floating-point variable instead of a valid number.
cliff@cpsc.ucalgary.ca (Cliff Marcellus) (07/19/89)
In article <20283@adm.BRL.MIL>, Leisner.Henr@xerox.com (Marty) writes: > What does NaN mean out of printf? > "NaN" stands for "Not a Number". It's an error generated by various mathlib routines, and is defined by IEEE for various binary function operations. (for example log10(0)) See the MATH(3M) manual page under 4.3BSD. Cliff Marcellus UUCP : {any backbone}!calgary!ssg-vax-a!cliff Institute for Space Research DOMAIN : cliff@ssg-vax-a.phys.UCalgary.CA Dept of Physics and Astronomy SPAN : CANCAL::CLIFF The University of Calgary "If it's not fun, don't do it!"
hjg@amms4.UUCP (Harry Gross) (07/19/89)
In article <20283@adm.BRL.MIL> Leisner.Henr@xerox.com (Marty) writes: >What does NaN mean out of printf? ^^^ Not A Number >(I assume it's some sorta float point error). Yup. >I haven't ever seen it documented anywhere. I have only seen this in Microsoft C compilers on PC's. Maybe it is moving :-) >marty >ARPA: leisner.henr@xerox.com >GV: leisner.henr >NS: leisner:wbst139:xerox >UUCP: hplabs!arisia!leisner > -- Harry Gross | reserved for | something really Internet: hjg@amms4.UUCP (we're working on registering)| clever - any UUCP: {jyacc, rna, bklyncis}!amms4!hjg | suggestions?
flint@gistdev.UUCP (07/20/89)
NaN is not a number. An easy way to get that is having a union, or by doing a cast (of a long to a float) when you shouldn't. For example, the bit pattern for the integer -1L (all bits set) does not correspond to any legal floating point value. SYS V has an isnan(3C) function to test if a value is legal floating point without generating an exeception. Flint Pellett, Global Information Systems Technology, Inc. 1800 Woodfield Drive, Savoy, IL 61874 (217) 352-1165 INTERNET: flint%gistdev@uxc.cso.uiuc.edu UUCP: {uunet,pur-ee,convex}!uiucuxc!gistdev!flint
jsalter@slo.uucp (James Salter) (07/20/89)
In article <23490@iuvax.cs.indiana.edu> bobmon@iuvax.cs.indiana.edu (RAMontante) writes: >NaN == Not a Number > >i.e., not a legitimate floating-point value. I'm reasonably certain that >this is defined by the IEEE floating-point format standard. A NaN is the Floating Point representation of non-legitimite (?) values. There are both Signalling NaNs and Quiet NaNs which operate differently with respect to exception handling. >the sorcerer's apprentice jim/jsalter PS/2 MathLib/FP IBM AWD, Palo Alto T465/(415)855-4427 UUCP: ..!uunet!ibmsupt!jsalter VNET: JSALTER@PALOALTO Internet: ibmsupt!jsalter@uunet.uu.net Disc: Any opinions are mine. "Reality Corrupts. Absolute Reality corrupts Absolutely." -- kaydin
burzio@mmlai.UUCP (Anthony Burzio) (07/22/89)
In article <588@amms4.UUCP>, hjg@amms4.UUCP (Harry Gross) writes: > >What does NaN mean out of printf? > ^^^ > Not A Number > I have only seen this in Microsoft C compilers on PC's. Maybe it is >moving :-) Just saw a NaN pop out of a FORTRAN type statement on our Hewlett Packard 835 running HP-UX... ********************************************************************* Tony Burzio * If you delete the passwd file and type Martin Marietta Labs * whoami, you get "Intruder alert" !!! mmlai!burzio@uunet.uu.net * - HP-UX 6.5 *********************************************************************
nagle@well.UUCP (John Nagle) (07/23/89)
In IEEE Floating Point, there is a value for the exponent that indicates that the mantissa, rather than representing a numeric value, represents a special code. At least the following codes are defined: positive infinity negative infinity not a number Uninitialized variables should be initialized to the "not a number" value, and some implementations do this. One gets positive infinity if you divide a positive number by zero, and negative infinity if you divide a negative number by zero. Try generating these values and see what happens when you print them on your implementation. John Nagle
ark@alice.UUCP (Andrew Koenig) (08/15/89)
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