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