Matlab-bitwise-operators
提供:Dev Guides
MATLAB-ビット演算
MATLABは、「ビット単位のand」、「ビット単位のor」、「ビット単位のnot」演算、シフト演算などのビット単位演算用のさまざまな関数を提供します。
次の表は、一般的に使用されるビット演算を示しています-
Function | Purpose |
---|---|
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 |
例
スクリプトファイルを作成し、次のコードを入力します-
あなたがファイルを実行すると、次の結果が表示されます-