Skip to content

Instantly share code, notes, and snippets.

@woodsleaf
Last active April 10, 2018 05:40
Show Gist options
  • Select an option

  • Save woodsleaf/29786d24987053d5087345848eec523f to your computer and use it in GitHub Desktop.

Select an option

Save woodsleaf/29786d24987053d5087345848eec523f to your computer and use it in GitHub Desktop.
Включение бита флага
def turnon(a):
mask = 0b100
desired = a | mask
# print(bin(desired))
# if a != desired:
return desired
a = 0b10111011
print(bin(turnon(a)))
#flip
#a = 0b11101110
#mask = 0b11111111
#desired = a ^ mask
#print(bin(desired))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment