More on bitfcns

Robert T. Short octave at phaselockedsystems.com
Sun Jul 19 09:39:48 CDT 2009


In my search for Truth and Justice I discovered the following bitshift 
behavior.

Is the following correct?

% This is what MATLAB does and it seems to make sense to me.
octave:1> bitshift(uint8(0:15),1,3)
ans =

  0  2  4  6  0  2  4  6  0  2  4  6  0  2  4  6

% MATLAB doesn't support this, but octave does.  Why would shifting
% a positive signed integer give different results than unsigned?
octave:2> bitshift(int8(0:15),1,3)
ans =

   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30




I will be out of town for a week.


Bob
--
Robert T. Short, Ph.D.
PhaseLocked Systems



More information about the Octave-maintainers mailing list