help-octave
[Top][All Lists]
Advanced

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

Re: Negative zeros?


From: Bill Denney
Subject: Re: Negative zeros?
Date: Wed, 14 Sep 2005 23:45:45 -0400 (EDT)

On Wed, 14 Sep 2005, Vic Norton wrote:

The 0's I had problems with were never computed. They were assigned. But because of the nature of my routine they were continually being multiplied by -1 (also an integer). If a 0 was multiplied an even number of times it stayed 0, and if a zero was multiplied an odd number of times it became -0. All of this was an artifact of my routine and had no meaning whatsoever. And the 0's and -0's popped up quite randomly in the output.

If you did things normally within octave, then the numbers you were using are not integers, they are double precision floating point numbers. If you were actually using ints, then they give the answer you expected:

octave:1> a = 0*-1
a = -0
octave:2> class(a)
ans = double
octave:3> a = int16(0)*int16(-1)
a = 0
octave:4> class(a)
ans = int16

Bill

--
"The towels in that hotel were so thick I could hardly close my
suitcase."
  -- Yogi Berra



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