# Re: Negative zero

From: Heavenly Avenger - NCL <avenger-ncl_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 23 2013 - 12:26:21 MDT

this could be somewhat useful to determine if an underflow has occurred from a negative or positive number. a little pointless nevertheless.
you can also x=-0.0 and it will be stored as -0.0 when you print it.

And this seems to be intentional, following IEEE 754, as reading and googling for ‘signed zero’ around.
Check this out: http://en.wikipedia.org/wiki/Signed_zero

- fabrício

From: Kyle Griffin
Sent: Tuesday, July 23, 2013 3:03 PM
To: ncl-talk
Subject: Negative zero

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
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: 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:26:42 2013

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