[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Negative zeros?
From: |
Paul Kienzle |
Subject: |
Re: Negative zeros? |
Date: |
Tue, 13 Sep 2005 21:49:28 -0400 |
How about:
function disp_abs_zero(a), a(a==0)=0; builtin('disp',a); end
dispatch('disp','disp_abs_zero',typeinfo([1,1]))
dispatch('disp','disp_abs_zero',typeinfo(1))
Now:
octave> disp([0 0 0]*-1)
0 0 0
Sorry, but there is no convenient way to dispatch on the print function
defined for the type.
- Paul
On Sep 13, 2005, at 8:15 PM, Vic Norton wrote:
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
-------------------------------------------------------------
-------------------------------------------------------------
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
-------------------------------------------------------------
- Negative zeros?, Vic Norton, 2005/09/12
- Re: Negative zeros?, David Bateman, 2005/09/13
- Re: Negative zeros?, Stefan van der Walt, 2005/09/13
- Re: Negative zeros?, Vic Norton, 2005/09/13
- Re: Negative zeros?, Paul Kienzle, 2005/09/13
- Re: Negative zeros?, Stefan van der Walt, 2005/09/14
- Re: Negative zeros?, Przemek Klosowski, 2005/09/14
- Re: Negative zeros?, Vic Norton, 2005/09/14
- Re: Negative zeros?, Bill Denney, 2005/09/14