Skip to content

Instantly share code, notes, and snippets.

@marcouberti
Created December 29, 2016 17:04
Show Gist options
  • Save marcouberti/18daf5ec445bfee8154d2481bcc7389d to your computer and use it in GitHub Desktop.
Save marcouberti/18daf5ec445bfee8154d2481bcc7389d to your computer and use it in GitHub Desktop.
Find LSB and MSB bit in Python
def bits_converter(x):
index = 0
bits = ""
while x is not 0:
bits += str(x & 1)
x = x >> 1
index+=1
return bits[::-1]
def lsb(x):
return x & 1
def lsb_alternative(x):
return x % 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment