Questions about NCEG
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Thu May 31 23:19:08 AEST 1990
In article <15570 at bfmny0.BFM.COM>, tneff at bfmny0.BFM.COM (Tom Neff) writes:
> Where does it say this? Requiring that "minus zero" have a distinct
> *internal* representation from "plus zero" says NOTHING about what a
> parser is supposed to do with the string "-0.0".
It's not just a different internal representation. It behaves differently.
There are three cases:
(a) the language defines -0.0 as one single token string.
Then the translation is governed by 5.6 and 3.1, so the answer
must be minus zero
(b) the language defines -0.0 as two tokens
then 0.0 converts to plus zero, and -(plus zero) is minus zero.
(c) the language defines -0.0 as two tokens, and says explicitly
that "- Literal" is translated as the value of "0 - Literal".
In that case, the translation must be plus zero.
Interpretation (c) violates the fairly strong recommendation of the
appendix, so although it is technically legal, it would be inadvisable.
> ANSI C does require that the strings "-0.0" and "0.0" parse to the same
> internal representation number (right Doug?).
OOPS. I would be surprised if it did: consider the IBM/370 series.
If I remember correctly, because they don't use a hidden bit, and they
do allow unnormalised numbers, they have a _lot_ of internal representations
of 0.0, _one_ of them being all zero bits. Certainly the B6700's floating-
point representation had that property (though I'd be surprised to find a
C compiler on the descendants of that machine).
--
"A 7th class of programs, correct in every way, is believed to exist by a
few computer scientists. However, no example could be found to include here."
More information about the Comp.std.c
mailing list