help-octave
[Top][All Lists]
Advanced

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

Re: Negative zeros?


From: Vic Norton
Subject: Re: Negative zeros?
Date: Tue, 13 Sep 2005 20:15:53 -0400

OK, so there isn't easy way. So I'll just have Perl strip all the minus signs from my -0.0's.

Regards,

Vic

At 10:06 PM -0400 9/12/05, John W. Eaton wrote:
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


--
*---* mailto:address@hidden
|     Victor Thane Norton, Jr.
|     Mathematician and Motorcyclist
|     Bowling Green, Ohio
*---* http://vic.norton.name



-------------------------------------------------------------
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]