MATLAB Functions Help Desk

bitshift

Purpose

Bit-wise shift

Syntax

Description

C = bitshift(A,n) returns the value of A shifted by n bits. If n>0, this is same as a multiplication by 2n (left shift). If n<0, this is the same as a division by 2n (right shift). A must be a nonnegative integer, which you can ensure by using the ceil, fix, floor, and round functions.

Examples

Shifting 1100 (12, decimal) to the left two bits yields 110000 (48, decimal).

See Also

bitand      Bit-wise AND

bitcmp      Complement bits

bitget      Get bit

bitmax      Maximum floating-point integer

bitor       Bit-wise OR

bitset      Set bit

bitxor      Bit-wise XOR



[ Previous | Help Desk | Next ]