[PYTHON] Bitoperation

print('Logische Summe')
print(0 | 0)
print(0 | 1)
print(1 | 0)
print(1 | 1)

print('Logisches UND')
print(0 & 0)
print(0 & 1)
print(1 & 0)
print(1 & 1)

print('Exklusive logische Summe')
print(0 ^ 0)
print(0 ^ 1)
print(1 ^ 0)
print(1 ^ 1)

print('Umkehren')
print(bin(0))
print(bin(~0))
print(bin(1))
print(bin(~1))

print('Verschiebung')
print(bin(1 << 0))
print(bin(1 << 1))
print(bin(1 << 2))
print(bin(1 << 3))

Ausführungsergebnis:

Logische Summe
0
1
1
1
Logisches UND
0
0
0
1
Exklusive logische Summe
0
1
1
0
Umkehren
0b0
-0b1
0b1
-0b10
Verschiebung
0b1
0b10
0b100
0b1000

Recommended Posts

Bitoperation
Logische Operation / Bitoperation 0
Bitmaske
Waren- (Kürzungs-) / Restberechnung durch Bitberechnung
Bitberechnung des Ringpuffers (hohe Geschwindigkeit)
[Python] Vektoroperation
Array-Betrieb usw. 1
Python-Betriebssystembetrieb
[Python] Matrixoperation
Pandas Operations Memorandum
PYTHON2.7 64-Bit-Version
Listen Sie die umgekehrte Operation auf
SparkFun moto: Bit I2C-Betrieb und Verwendung von MicroPython