Re: On writing negative zero - with or without sign

Ron Shepard wrote:
In article <1184572698.921310.254810@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Terence <tbwright@xxxxxxxxx> wrote:

If a real value very close to zero has to be expressed in a limited
number of fractional digits, but these digits are all zeroes after
the decimal point, then the appropriate sign should be prefixed to
the values to indicate which side of absolute zero the values lies.

This is the basis of the problems. There is a way to designate -0.0
in this way (by using the sign bit), but there is no way to
designate a +0.0 in this way that is distinct from the actual 0.0.

Floating point is an approximation to reals. Different floating
point implementations may have different interpretations of the
approximations they provide. In IEEE floating point, there
are two different approximations to zero. The concept of
*exactly* zero is *equally* represented by either of those
approximations (hence, the two compare equal to each other).

However, the two approximations differ in that they represent
different sets of values which intersect at one point: exactly zero.
So, the sign may carry important informaion. Conversions to
other bases should preserve the sign.

If, in hardware, there were a way to designate and differentiate
-0.0, 0.0, and +0.0, then there would be no problems, everyone would
know what the three values mean.

Actually, that description exemplifies the problem. Most of
the IEEE operations specify very clearly what the sign of the
result should be. Even when the magnitude (to the limit of the
representation) is zero, the sign bit usually preserves some
information. The only exception is the result of an add or a
subtract. Here the sign of the result is indeterminate (and the
IEEE standard allows the implementation to pick either one).
So, a signless zero would most naturally fit this result. But
that means that, far from representing *exactly* zero, this
new value represents the union of the two approximations
represented by the signed zeros. It's *less* exact. (Indeed
it's *much* less exact since you didn't arrive at zero by
underflow, but by cancellation of the leading bits. Such
concepts were intended to be addressed by interval arithmetic.)

So the real problem is that people tend to think that programs
can represent, manipulate, or produce metaphysically perfect
"exact" zeros in the first place. Such things are fabulous

J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


Relevant Pages

  • Re: On writing negative zero - with or without sign
    ... I sure hope that a program can represent an exact zero. ... programs represent, manipulate, and produce approximations. ... (which is not what floating point does) ...
  • Re: how come calculus can be exact?
    ... >approximations(neglecting the infinitesimal which tends to zero) at ... >its basic definition level? ... you are taking a limit of approximations as something goes ... is the exact result. ...
  • Re: C ++ help!
    ... doubles and I am using a loop to calculate doubles up to an ... at the beginning i get normal approximations and then ... So next line you divide by zero so y is undefined ... Registered Linux User #300464 Machine Id #188886 ...
  • Re: Strange result in Excel 2000
    ... None of your numbers have exact binary representations, and hence must be approximated. ... The binary approximations to the numbers involved in the final subtraction are ... What they did is to assume that if a final subtraction involves two numbers that are equal to at least 15 decimal digits, then Excel will arbitrarily zero the result on the assumption that the non-zero difference is residue from binary approximations. ...
  • Re: When is zero not zero???
    ... Almost all computer software (including Excel) do binary math following ... result is zero. ... The trailing +0 is needed to make the effects of these approximations ... the result even if the numbers are not equal beyond 15 decimal digits. ...