bitshift
Shift bits specified number of places
Description
returns intout = bitshift(A,k)A shifted
to the left by k bits, equivalent to multiplying
by 2k. Negative values
of k correspond to shifting bits right or dividing
by 2|k| and rounding
to the nearest integer towards negative infinity. Any overflow bits
are truncated.
If
Ais an array of signed integers, thenbitshiftreturns the arithmetic shift results, preserving the signed bit whenkis negative, and not preserving the signed bit whenkis positive.If
kis positive, MATLAB® shifts the bits to the left and insertsk0-bits on the right.If
kis negative andAis nonnegative, then MATLAB shifts the bits to the right and inserts|k|0-bits on the left.If
kis negative andAis negative, then MATLAB shifts the bits to the right and inserts|k|1-bits on the left.
assumes intout = bitshift(A,k,assumedtype)A is
of type assumedtype.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced before R2006a