octave-maintainers
[Top][All Lists]
Advanced

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

Re: signbit and logical tests


From: Michael D. Godfrey
Subject: Re: signbit and logical tests
Date: Sat, 09 Feb 2013 22:02:59 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/09/2013 09:26 PM, John W. Eaton wrote:
On 02/09/2013 09:02 PM, Michael D. Godfrey wrote:
I looked a bit more at the "logical" tests as described in Sections 4.6-8.
If signbit() returned a logical it would fit with "isxxxx" functions and
make more
sense. Referencing Section 4.6 through 4.8 in the signbit() documentation
would then make this all fit together and more understandable.

Is this a useful idea?

The signbit function in Octave is just a simple wrapper around the system library signbit function, and that returns the value of the sign bit as an integer. I don't know whether it would be a good idea to change that definition for Octave. The other function that I know of in Matlab that returns something different from what the C library function returns is strcmp. So there is precedent for that kind of thing. Or, if you want a predicate-style function, maybe we should have isnegative instead?

jwe
This does not quite appear to be the case because this problem started with bug #38291 which showed that on at least one 32bit system (Ubuntu) the returned value for true is 512. That is why my test for == 1 failed. And, ss = signbit(-2) returns ss = 1 class: double on my system (64bit).

In any case, do you consider the return value of 512 to be a problem?

Michael



reply via email to

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