octave-maintainers
[Top][All Lists]
Advanced

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

Re: bitshift of int8, int16, etc?


From: Daniel J Sebald
Subject: Re: bitshift of int8, int16, etc?
Date: Mon, 25 Jun 2007 19:11:45 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

John W. Eaton wrote:
On 25-Jun-2007, Daniel J Sebald wrote:

| I get your point, but that example is fraught with all kinds of
| compiler casts.  The (x << 1) is probably cast to a regular int
| first and then bit shifted.

Yes, that was my point (and it is promoted to int as required by the
C rules for usual arithmetic conversions, so you can remove probably
from the above).

Since no other operations on the intX types in Octave/Matlab do that
kind of promotion, I don't think we should do it for these either.  So
there is one immediate difference between how C behaves and how it
seems Octave should for the same operator.

Oh, yeah I wasn't following.  Well, I'd say the patch from Dave is a first step 
and worth checking in.  I think the options

[result, overflow] = bitshift (A, S, "saturate")

would have some value, but that is a big jump.  Might be hard for me to write 
such a thing too if every change I make to the header file requires so much 
recompilation.

Dan


reply via email to

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