bitshift
Shift bits specified number of places
Syntax
Description
returns the value of c = bitshift(a,k)fi object a with
stored integer value shifted by k bits.
The shift is arithmetic and behaves like b = a.*2^k with the value of
b cast to the type of input a. The cast of
b may involve overflow or loss of precision.
The OverflowAction property of a is obeyed, but
the RoundingMethod is always Floor. If obeying the
RoundingMethod property of a is important, try
using the pow2 function.
When the overflow action of a is Saturate, the
sign bit is always preserved. When the overflow action of a is
Wrap and k is negative, the sign bit is preserved.
When the overflow action of a is Wrap and
k is positive, the sign bit may change.
When
kis positive, 0-valued bits are shifted in on the right.When
kis negative andais unsigned, or a signed and positivefiobject, 0-valued bits are shifted in on the left.When
kis negative andais a signed and negativefiobject, 1-valued bits are shifted in on the left.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced before R2006a