Signed zeros: is this a bug?

Paddy paddy3118 at googlemail.com
Sun Mar 11 18:49:24 EDT 2007


On Mar 11, 9:28 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Dennis Lee Bieber <wlfr... at ix.netcom.com> writes:
>
> >    Pardon? What is "the right thing with signed zeros"... In the last
> > 30 years I've been on machines that normalize floating zero into a true
> > zero (all bits are zero: mantissa, exponent, and sign). This is the
> > first time I've even seen a variable output as a negative 0.0!
>
> Most machines these days use IEEE 754 which supports negative zero.
>
> http://en.wikipedia.org/wiki/Negative_zero

Isn't negative zero mathematically the same as zero? Isn't -0 just an
artefact of the representation of floating point numbers? Shouldn't
f(0) == f(-0) for all functions f?
I read the wikipedia article about meteorologists using -0 to denote a
negative number rounded to zero for the purposes of binning, i.e. if
you want to tally days with temperature above and below zero, but it
doesn't seem right. You should arrange for any temperature to be in
only one range and record temperatures to their determined accuracy. a
temperature of zero would only be in one bin and if a temperature is
read as -0.2 and th rounding says it should be taken as zero then it
should go in the same bin as any positive reading that is rounded to
zero.
Getting back to Python, shouldn't we strive to remove any distinction?
a zero is a zero regardless of sign and a function like atan returning
one of two different vaues for an argument of zero is actually
mathematically not a bad thing to do?

- Paddy.




More information about the Python-list mailing list