octave-maintainers
[Top][All Lists]
Advanced

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

Re: signbit and logical tests


From: Daniel J Sebald
Subject: Re: signbit and logical tests
Date: Sat, 09 Feb 2013 23:48:21 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 02/09/2013 09:02 PM, Michael D. Godfrey wrote:
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.

Just curious how that is coming about. Any guess? I would think that C defines a logical true as 1. If this where a sign bit test then 512 is the result

1000000000

Such a thing could result if the underlying assembly is using a register shift (albeit incorrect shift) to isolate the sign bit.

Dan


reply via email to

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