You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
332 B
22 lines
332 B
7 years ago
|
#! /usr/bin/env python2
|
||
|
|
||
|
def printbits(n):
|
||
|
if n < 2:
|
||
|
return str(n & 1)
|
||
|
rest = n >> 1
|
||
|
d = n & 1
|
||
|
return printbits(rest) + str(d)
|
||
|
|
||
|
def modifybit(n):
|
||
|
return 1 << n
|
||
|
|
||
|
test = 0b10010101111
|
||
|
|
||
|
print bin(test)
|
||
|
print bin(test | modifybit(3))
|
||
|
|
||
|
# bin((1 << 6) - 2)
|
||
|
|
||
|
#print bin(1292002343)
|
||
|
#print printbits(1292002343)
|