-0.0 (WHAT?)

Jarvis, Robert P. (Contingent) Jarvisb at timken.com
Thu Jun 22 19:18:20 UTC 2000


> -----Original Message-----
> From: jchludzinski at worldkey.net [mailto:jchludzinski at worldkey.net]
> Sent: Thursday, June 22, 2000 10:18 AM
> To: Squeak mailing list!
> Subject: -0.0 (WHAT?)
> 
> 
> I'm coding a cubic spline algorithm for 3D points and during 
> the computation I got:
> 
> -0.0.
> 
> If I'm not mistaken, the IEEE-754 floating point standard 
> don't allow negative 0.0.  What's up?


Hrrrmmmm...  I recall something similar being encountered a while back.
<rustle-rustle-rustle>  Ah, here it is...

> -----Original Message-----
> From: William O. Dargel [mailto:wDargel at shoshana.com]
> Sent: Wednesday, February 17, 1999 2:18 PM
> To: squeak at cs.uiuc.edu
> Subject: Re: Hardware or System Incompatibility
> 
> 
> Dan Ingalls wrote:
> 
> > B.  Secondly, Andres reports that
> >                 0.0 raisedTo: 0.75 ==> -0.0 on his machine,
> >         whereas I get 0.0 on my Mac.
> >
> >         If you get -0.0, please also supply the information 
> requested above.
> 
> I already reported directly to Dan that I have this problem 
> on Windows.
> It seems to have started on the transition from version 1.31 to 2.0.
> Based on some of the other messages here, I got interested in 
> exploring
> it a bit further.
> 
> I don't understand floating point representation, and so 
> don't know what
> to make of this. So I present the following results of printing
> expressions in the context of Float in hopes that someone 
> else will know
> what to make of it.
> 
> (0.0 raisedTo: 0.75)                     -0.0
> (0.0 raisedTo: 0.75) = NegativeInfinity  true
> (0.0 raisedTo: 0.75) = NegativeZero      true
> (0.0 raisedTo: 0.75) = Infinity          true
> (0.0 raisedTo: 0.75) = NaN               true
> (0.0 raisedTo: 0.75) = 1.2               true
> NaN = Infinity          true
> NaN = NegativeInfinity  true
> NaN = NegativeZero      true
> NaN = 1.2               true
> NegativeZero = NegativeInfinity  false
> Infinity = NegativeInfinity      false
> 
> (0.0 raisedTo: 0.75) hex 'FFF8000000000000'
> NegativeInfinity hex     'FFF0000000000000'
> NegativeZero hex         '8000000000000000'
> Infinity hex             '7FF0000000000000'
> NaN hex                  '7FF8000000000000'
> 1.2 hex                  '3FF3333333333333'
> 
> Ah, the -0.0 appears to be a 'negative' version of NaN. It really
> surprises me though that NaN seems to be equal to _any_ Float value. 
> Is that normal behavior?
> 
> I was going to check NaN behavior in 1.31, but it wasn't a class
> variable back then.
> 
> -------------------------------------------
> Bill Dargel            wdargel at shoshana.com
> Shoshana Technologies
> 100 West Joy Road, Ann Arbor, MI 48105  USA
> 

I remember delving into this a bit and IIRC it turned out to revolve around
how the C runtime libs on various platforms handled an attempt to take the
logarithm of a negative number.  Some platforms answered a NaN, some a
negative zero, some answered a reasonable-but-wrong value, some crashed and
burned in the runtime lib, but basically it was platform (and sometimes
debug-build vs. production-build) dependent.  Some changes were made to the
various raisedToXXXX: methods which *should* have taken care of this.  Maybe
your code has uncovered a problem here, or in something similar.  If you can
post the code that causes this error and some examples that cause the error
I expect there are those here (group includes: self :-) who'd be interested
in taking a look at it.

Bob Jarvis
Compuware @ Timken





More information about the Squeak-dev mailing list