Calculation returning NaN

Joe Porkka jap at convex.cl.msu.edu
Tue Jan 29 05:49:19 AEST 1991


fineberg at caip.rutgers.edu (Adam B. Fineberg) writes:


>I was wondering if someone could point me to a source of information
>about the math error NaN.  I understand that this means not a number

I've got to motorola handbook right here....
(If you want the manual, call 1-800-555-1212 to ask for morola number, call
morola and ask for m68000 programmers reference manual. I thinks its <$10)

Well, if a=Nan, and b= anynumber, then most things like
  a<b, a*b, etc... return NaN.

  On page 1-37 theres a nifty table for the FADD instruction

	source	 in range	| zero		| infinity
		+       - 	  +	   -	  +     -
=====================================================================
destination
	+
    in range	add		add		 +inf  -inf
	-

	+			+0.0	+-0.0
    zero	add				  +inf	-inf
	-			+-0.0   -0.0

	+	+inf		   +inf		  +inf	NaN
    infin.
	-	-inf		   -inf		   NaN   -inf



So if a=-inf and b=+inf, result = NaN
	+inf       +inf  result = +inf


Also, things like 4.0/0.0 == NaN



More information about the Comp.lang.c mailing list