octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: imag () function detail regarding -0.0000


From: Michael D Godfrey
Subject: Re: imag () function detail regarding -0.0000
Date: Wed, 12 Sep 2012 12:05:48 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0

On 09/12/2012 03:51 AM, John W. Eaton wrote:
I don't think we should change Octave so that the '-' is not
displayed, and I would definitely be against checking for and dropping
the sign of zero every time we do some computation.  If -0 can be
generated, it should be displayed.  Consider things like

  1/(1/-Inf)

if you drop the - from (1/-Inf) == -0, this _expression_ would result in
Inf -- how does that make sense?  If you decide to not display it (as
Matlab does) then things become somewhat confusing if you break the
_expression_ into parts and evaluate them separately: x = 1/-Inf
produces -0 but it is displayed as 0, so you think, OK, I have 0.
Then you use that result in the _expression_ 1/x and you get -Inf.
What?

jwe
In partial atonement for my starting off with a remark about integers,
not floating point, here is an excerpt from Kahan's Lecture Notes:

Note that +0 and -0 are distinguishable and follow obvious rules specified by IEEE 754 even though floatingpoint
arithmetical comparison says they are equal; there are good reasons to do this, some of them discussed in
my 1987 paper “ Branch Cuts ... .” The two zeros are distinguishable arithmetically only by either division-byzero
( producing appropriately signed infinities ) or else by the CopySign function recommended by IEEE 754 /
854. Infinities, SNaNs, NaNs and Subnormal numbers necessitate four more special cases.

This is from :

IEEE Standard 754 for Binary Floating-Point Arithmetic


I think that his "Branch Cuts..." paper is available on the web.
Anyhow, the result is that keeping, and displaying, -0 is really
required.  Matlab does not seem to have this quite right, but this
is not really important as compared to being correct with respect
to 754/854.

Michael


reply via email to

[Prev in Thread] Current Thread [Next in Thread]