Convert integer to binary in python and compare the bits
How to convert a int n into binary and test each bit of the resulting
binary number?
I have just got the following after a lot of googling:
def check_bit_positions(n, p1, p2):
print int(str(n),2)
However i get an error invalid literal for int() with base 2. Let me know
how can i get binary form of the input number and test each bit at
position p1 and p2
No comments:
Post a Comment