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: Fotios Kasolis
Subject: Re: test sign of signed zero?
Date: Sun, 19 Dec 2010 15:28:27 +0100



-----Original Message----- From: Eric Chassande-Mottin
Sent: Sunday, December 19, 2010 2:49 PM
To: address@hidden
Subject: test sign of signed zero?



hi,

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 ?

thanks,
e
--
View this message in context: http://octave.1599824.n4.nabble.com/test-sign-of-signed-zero-tp3094440p3094440.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


The only idea that I have (after trying some conversions to binary but the function dec2base works with positive numbers only) is the following
octave.exe:38> a = -0
a = -0
octave.exe:39> b = num2str(a)
b = -0
octave.exe:40> findstr (b, "-")
ans =  1
octave.exe:41> findstr (b, "whatever")
ans = [](0x0)

and then use isempty to decide the case! Not very clever but does the desired. Before doing this, think how necessary is it cause it seems strange to want to find the sign of a zero.

Enjoy
Fotios


reply via email to

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