Questions about NCEG

Patricia Shanahan ps at fps.com
Fri Jun 1 05:54:40 AEST 1990


In article <13028 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>In article <1990May30.205436.11534 at twinsun.com> eggert at twinsun.com (Paul Eggert) writes:
>>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.
>
>I sometimes wonder why I waste my time responding.
>IEEE 754 does not apply to C source code!

The issue is even clearer for Fortran. According to the May 89 Fortran 8x
draft "Each numeric type includes a zero value, which is considered to be 
neither negative nor positive. The value of a signed zero is the same as 
the value of an unsigned zero." (there is a similar statement in the ANSI
Fortran 77 standard). For output conversion the draft specifies "a minus
if the value of the internal datum is negative, or an optional plus sign
otherwise...". According to the standard "+0.0" would be O.K., but "-0.0"
is prohibited.

In other words, there is no experiment you could perform in a standard
conforming program on a standard conforming Fortran implementation that 
would distinguish two different values of zero from each other.

Fortran users and implementers generally seem to take floating point types
far more seriously than typical C users and implementers. If distinguishing
-0.0 from 0.0 is such a good thing, why is it so expressly prohibited, not
just in early Fortran standards, but in the draft for the next Fortran 
standard?

I realize that C can (and does) have different rules from Fortran for
floating point arithmetic. However, there is about 30 years experience of
implementing numerical algorithms contributing to the Fortran standard.
Is it wise to ignore the choices that have been made for Fortran in this
area?

Note that there is nothing about this that prevents a standard conforming
Fortran implementation from being based on an IEEE floating point conforming
platform. It just requires a little care on the part of the language 
implementer to ensure that all zeros are equal to each other and are never
printed with minus signs.
--
	Patricia Shanahan
	ps at fps.com
        uucp : ucsd!celerity!ps
	phone: (619) 271-9940



More information about the Comp.std.c mailing list