Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!ibmpa!slo!jsalter From: jsalter@slo.uucp (James Salter) Newsgroups: comp.lang.c Subject: Re: Not A Number in IEEE Math Message-ID: <4285@ibmpa.UUCP> Date: 27 Feb 90 21:07:14 GMT References: <44@newave.UUCP> Sender: news@ibmpa.UUCP Reply-To: jsalter@slo.UUCP (James Salter) Organization: IBM AWD, Palo Alto Lines: 47 In article mac@ardent.com (Michael McNamara) writes: > > In article <44@newave.UUCP> john@newave.UUCP (John A. Weeks III) writes: > >> My understanding of the NaN (not a number) value in IEEE math is >> that once you get NaN, the operators +, -, /, *, and = are supposed >> to propagate the NaN value. Is my understanding correct? >> >> Well, while using MetaWare's HIGH-C compiler for the 80386 chip, I >> have discovered that: >> NaN / NaN = 1.0 >> and >> 0.0 * NaN = 0.0. >> Is this correct behavior? I think HIGH-C is broken... >> -john- > This behaviour is not correct. Possibly the compiler has >folied you by presubstituting 1.0 for A/A and 0.0 for 0.0 * A at >compile time. Metaware hasn't been very good about identifying and correctly dealing with NaNs. They generate code which does not have the jp (jump if parity) instruction around the compare of doubles. Because of the flag bits which get set in the 386, if the jp instruction is placed after the normal conditional jump, even if one of the args is a NaN, it may *still* not reach the jump if parity instruction. If you check the assembler code, this should reveal itself. To be fair, Metaware isn't alone in this, lots of compilers don't do this right. > Or, perhaps your hardware traps into the OS for IEEE exceptions >and the OS's handling of source exceptions is broken. Probably not. > Or, perhaps your hardware is not IEEE compliant.... Well, sorta. Depending on what 80386 level of hardware you have, you may have some microcode problems. But those should be getting fixed soon. Contact your local Intel dealer about errata sheets. Especially if you have an 80387 chip in there, too. >Michael McNamara (St)ardent, Inc. mac@ardent.com jim/jsalter IBM AWD T465/(415)855-4427 VNET: JSALTER at PALOALTO UUCP: ..!uunet!ibmsupt!jsalter Disc: Any opinions are mine. IP: ibmsupt!jsalter@uunet.uu.net "PS/2 it, or DIE!"