Wie man sich in Ganzzahl in Python verändert
# bit is 0 indexed
def set_bit(value, bit):
return value | (1<<bit)
def clear_bit(value, bit):
return value & ~(1<<bit)
set_bit(4, 0) # set bit 0 in 4(100) becomes 5(101)
clear_bit(5, 0) # clear bit 0 in 5(101) becomes 5(100)
Anxious Alligator