Article View: comp.std.c
Article #1340Re: Questions about NCEG
From: Paul Eggert
Date: Wed, 30 May 1990 20:54
Date: Wed, 30 May 1990 20:54
34 lines
1751 bytes
1751 bytes
I wrote:
There are ways to say the IEEE numbers in ANSI C + IEEE 754:
#define minus_0 (-0.0)
#define infinity (1e300*1e300)
...
Doug Gwyn replied:
These don't work. -0.0 is NOT a "minus zero"; it's identical to 0.0.
Surely ANSI C doesn't require this; it is inconsistent with IEEE 754.
For example, given the following strictly conforming ANSI C program
#include <stdio.h>
int main() { printf("%g\n", -0.0); return 0; }
an implementation that conforms to both ANSI C and IEEE 754 must print "-0",
not "0". IEEE 754 doesn't specify the output format, but it does require that
+0 and -0 be output differently, and "-0" is the only real choice here.
This is not purely academic. Of the two C compilers on my IEEE 754-based
machine, one prints "-0" and the other "0" when given the above program. I've
sent a bug report to the latter's implementer, and fully expect it to get fixed.
Finally, Gwyn wrote:
Assuming that 1.0e+300*1.0e+300 is not representable as a
(floating-point) number, the behavior is explicitly undefined...
(Steve Clamage made a similar point.)
True, if you assume only conformance to ANSI C.
But I explicitly assumed conformance to both ANSI C and IEEE 754.
Technical Details
Message-ID:
<1990May30.205436.11534@twinsun.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!uci-ics!ucla-cs!twinsun!eggertReferences:
<230@taumet.COM> <3094@goanna.cs.rmit.oz.au> <1990May29.193451.6533@twinsun.com> <13016@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!uci-ics!ucla-cs!twinsun!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: comp.std.c,comp.std.misc Subject: Re: Questions about NCEG Message-ID: <1990May30.205436.11534@twinsun.com> Date: 30 May 90 20:54:36 GMT References: <230@taumet.COM> <3094@goanna.cs.rmit.oz.au> <1990May29.193451.6533@twinsun.com> <13016@smoke.BRL.MIL> Sender: usenet@twinsun.com Organization: Twin Sun, Inc Lines: 34