help-octave
[Top][All Lists]
Advanced

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

Negative zeros?


From: John W. Eaton
Subject: Negative zeros?
Date: Mon, 12 Sep 2005 22:06:26 -0400

On 12-Sep-2005, Vic Norton wrote:

| Look at the following code
|     octave> CS = [ 0 0 0 ]
|     CS =
| 
|       0  0  0
| 
|     octave> CS *= -1
|     CS =
| 
|       -0  -0  -0
| 
| I find this a real annoyance. To paraphrase Gertrude Stein:
|     A zero is a zero is a zero.
| Is there some easy way to stop Octave from outputting negative zeros?

No.

Does it matter?  -0 == 0.  But I think it is useful to keep the sign.
It is also what other languages do (Octave is not doing anything
tricky to give -0 results), and there is some logic to it.  It is also
the IEEE standard behavior for floating point arithmetic.

For more info, take a look at the section on signed zeros in the paper 
What Every Computer Scientist Should Know About Floating-Point
Arithmetic (google the title and you will find it on the web).

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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