help-octave
[Top][All Lists]
Advanced

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

Re: test sign of signed zero?


From: Andy Buckle
Subject: Re: test sign of signed zero?
Date: Sun, 19 Dec 2010 14:23:28 +0000

> I'd like to test the sign of a variable that can be a signed zero.
>
> octave:1> a=-0
> a = -0
> octave:2> sign(a)
> ans = 0
>
> sign() does not work. any suggestions ?

I am not sure this is possible using m-code.

http://www.gnu.org/s/libc/manual/html_node/Infinity-and-NaN.html

"Negative zero behaves identically to zero in all calculations, unless
you explicitly test the sign bit with signbit or copysign"

Unless there is an octave function that does that, you may need to
write an oct file to get at the bits. Out of interest, why do you need
to know?

-- 
/* andy buckle */


reply via email to

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