matlab位运算函数列表入下
函数 | 目的/作用 |
---|---|
bitand(a, b) | Bit-wise AND of integers a and b |
bitcmp(a) | Bit-wise complement of a |
bitget(a,pos) | Get bit at specified position pos, in the integer array a |
bitor(a, b) | Bit-wise OR of integers a and b |
bitset(a, pos) | Set bit at specific location pos of a |
bitshift(a, k) | Returns 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 infinite. Any overflow bits are truncated. |
bitxor(a, b) | Bit-wise XOR of integers a and b |
swapbytes | Swap byte ordering |
例子,
1. &按位与运算 bitand
takemsg4 = bitand( msg, 240) ;
2. |按位或运算 bitor
cover1( i, j) = bitor( cover1( i, j) , shiftmsg4( i, j) ) ;
3. 移位 bitshift
shiftmsg4 = bitshift( takemsg4, - 4) ;