Numpy-bitwise-or
提供:Dev Guides
NumPy-bitwise_or
入力配列の整数のバイナリ表現の対応するビットのビット単位のOR演算は、* np.bitwise_or()*関数によって計算されます。
例
import numpy as np
a,b = 13,17
print 'Binary equivalents of 13 and 17:'
print bin(a), bin(b)
print 'Bitwise OR of 13 and 17:'
print np.bitwise_or(13, 17)
その出力は次のとおりです-
Binary equivalents of 13 and 17:
0b1101 0b10001
Bitwise OR of 13 and 17:
29
次の表を使用して、この出力を確認できます。 次のビットごとのOR真理値表を検討してください。
A | B | OR |
---|---|---|
1 | 1 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
1
1
0
1
AND
1
0
0
0
1
結果
1
1
1
0
1
11101に相当する10進数は29です。