Signed zeros: is this a bug?

Paddy paddy3118 at googlemail.com
Mon Mar 12 06:35:25 CET 2007


On Mar 11, 10:49 pm, "Paddy" <paddy3... at googlemail.com> wrote:
> 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.

A big thanks to Paul and Andre,
I think I have it now. The OP is investigating multivalued functions
where the function converges to different values when approached from
different directions. Floating point arithmetic being a best
compromise solution to the rational number system, distinguishes
between zero and minus zero as an important part of the compromise.
The OP wants to compute a function of zero and minus zero distinctly
and is hampered by Python not preserving the zero/minus zero
distinction in some cases - hence it being a bug.

Swell, Ta!

- Paddy.

Hey, I'm still learnin'. Sweet!




More information about the Python-list mailing list