Negative zero

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 23 2013 - 12:03:30 MDT

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

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

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