Re: Negative zero

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 23 2013 - 12:50:20 MDT

Thanks for the quick feedback, everyone. I had some idea of underlying
floating point math in my head, but had long forgotten the comp sci reasons
behind it. I'm still not sure it's particularly useful, but I suppose
there's likely little we can do to "correct" it here - oh well. Thanks
again.

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

On Tue, Jul 23, 2013 at 1:26 PM, Heavenly Avenger - NCL <
avenger-ncl@avenger.ws> wrote:

> 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 <ksgriffin2@wisc.edu>
> *Sent:* Tuesday, July 23, 2013 3:03 PM
> *To:* ncl-talk <ncl-talk@ucar.edu>
> *Subject:* [ncl-talk] 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
> 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
>
>

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

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