-0.0 and comp.std.c

David Hough uunet!Eng.Sun.COM!dgh
Thu May 31 11:17:03 PDT 1990


For those of you who are following this bizarre discussion in comp.std.c,
rest assured that any implementation of any programming language that
claims to provide an IEEE 754-conforming programming environment, and
interprets
	x= -0.0;
to mean anything other than assigning a zero value with negative sign bit
to x, has no understanding of IEEE arithmetic and probably does not conform
in a number of other aspects.   If as Doug Gwyn claims, the X3J11
standard somehow requires some other behavior, then the X3J11 standard
is broken in another way that I missed during the public review periods.

The purpose of a programming language is first of all to serve the programmer's
needs.  I can't think of a-prior reason why anybody who wrote the line
above would think that it should be equivalent to
	x= 0.0;
otherwise he would have written the latter.

Well there is a workaround of course:
	x= 0.0;
	x= -x;
but it's this kind of gratuitous trouble that argues against Fortran
programmers learning C.

Fortran has its own dumb ideas, of course; fcvs enforces the Fortran-77
requirement that you can't print -0 in formatted output.




More information about the Numeric-interest mailing list