Re: Negative zero

From: Gus Correa <gus_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 23 2013 - 12:24:02 MDT

Hi Kyle.

I think the IEEE floating point standard requires representations
for signed zeros (+0 an -0).
As far as I know, the (two's complement) integer representation
has a single zero, though.
I may be wrong, but NCL is probably just echoing the
underlying results of the floating point operations.

https://en.wikipedia.org/wiki/Signed_zero

Gus Correa

On 07/23/2013 02:03 PM, Kyle Griffin wrote:
> Hi all,
>
> Simple bug that doesn't appear to have been documented or discussed on
> the list previously. Although it's simple to work around in my
> applications, I don't believe the functions on lines 2 and 4 provide the
> expected results on their respective subsequent lines. It would appear,
> to me, that the issue of 0*-1=-0 only occurs when floating point numbers
> are involved in the calculations, even if only partially. All seems to
> work fine if solely integers are used. Similar issues occur if one
> attempts to directly assign "-0" or "-0.0" to a variable.
>
> ncl 0> x=0
> ncl 1> print(x*-1)
> (0)0
> ncl 2> y=(/0,0.5,1.0/)
> ncl 3> print(y*-1)
> (0)-0
> (1)-0.5
> (2)-1
> ncl 4> z=(/0.0,0.5,1.0/)
> ncl 5> print(z*-1)
> (0)-0
> (1)-0.5
> (2)-1
> ncl 6> a=(/0,1,2/)
> ncl 7> print(a*-1)
> (0)0
> (1)-1
> (2)-2
>
>
> Kyle
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu <mailto:ksgriffin2@wisc.edu>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 23 12:24:13 2013

This archive was generated by hypermail 2.1.8 : Thu Jul 25 2013 - 21:02:42 MDT