NumPy - bitwise_or
L'opération OU au niveau du bit sur les bits correspondants des représentations binaires d'entiers dans les tableaux d'entrée est calculée par np.bitwise_or() fonction.
Exemple
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)
Sa sortie est la suivante -
Binary equivalents of 13 and 17:
0b1101 0b10001
Bitwise OR of 13 and 17:
29
Vous pouvez vérifier cette sortie à l'aide du tableau suivant. Considérez la table de vérité OR binaire suivante.
UNE | B | OU |
---|---|---|
1 | 1 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
1 | 1 | 0 | 1 | ||
ET | |||||
1 | 0 | 0 | 0 | 1 | |
result | 1 | 1 | 1 | 0 | 1 |
L'équivalent décimal de 11101 est 29.