Professional Documents
Culture Documents
http://www.tuto rialspo int.co m/matlab/matlab_bitwise _o pe rato rs.htm Co pyrig ht tuto rials po int.co m
MAT LAB provides various functions for bit-wise operations like 'bitwise and', 'bitwise or' and 'bitwise not'
operations, shift operation, etc.
bitg et(a,pos) Get bit at specified position pos, in the integ er array a
bitshift(a, k) Returns a shifted to the left by k bits, equivalent to multiplying by 2k. Neg ative
values of k correspond to shifting bits rig ht or dividing by 2|k| and rounding to the
nearest integ er towards neg ative infinite. Any overflow bits are truncated.
Example
Create a script file and type the following code:
c =
12
c =
61
c =
49
c =
240
c =
15