[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zeroes and infinities



Nick Maclaren wrote:
Peter Henderson <petercbh@xxxxxxxxxxx> wrote:
If the sign of zero bothers you, ignore it. It will only cause you problems ...
.
.
.
No, that is wrong.  The problem is that you CAN'T ignore it, because
IEEE 754, the way that it is interpreted, Java, C99 and so on make
the sign of zero cause wrong answers in all sorts of ways.
An example would help me to understand what you are getting at.
Because copysign is defined for zero, language sign functions no
longer give an error - so you don't get told when you make a mistake.
This is a matter of poor compiler or library implementation. The sign type function, and its close cousins the copysign functions come with various definitions. Differnet languages define different versions. The FORTRAN version, for example, returns 1 for zero.
Because IEEE 754 forbids stopping on serious exceptions
This is definitely not true. IEEE 754 states an implementation "should" provide the ability to define alternative exception handling procedures. One might quibble that it also suggests these should behave like functions that return a value, but it certainly does not forbid stopping and I don't think the original committee ever intended such a thing. The draft of IEEE 754R has moved this to a normative annex, adding various desired behaviours but dropping the requirement that overflow and underflow return scaled values. In fact, stopping is about all anyone does, usually to start a debugger or to dump memory for later debugging.
, and languages generally can't support its flags (and that DOES include C99), 
you
have to rely on the values.  And dividing by a zero turns it into a signed 
infinity :-(
This is hardly IEEE 754's fault. Many languages have the facility to specify a function as a trap handler, but that is all that is generally available. Few, if any, languages support sophisticated responses. Similarly, the type of traps, i.e. an alternative execution path, envisaged by the IEEE 754 standard cause real complications for modern processors with deep pipelines and the possibility of out-of-order instruction execution. Flags cause similar problems. It is generally faster and easier to check the return values.
And then there is the whole morass of C99's bizarre interpretations
of the signs of zero in math.h and, God help us all, complex numbers.
Numerous people have observed that language standards committees seem to consider floating point support as an unfortunate necessity and the annexes of the draft IEEE 754R contains a number of what can only be described as pleas for better support.

Regards,
Peter Henderson

754 | revision | FAQ | references | list archive