set_bit in integer

DeaD_EyE Sep 21st, 2018 (edited) 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def set_bit(integer, bit_number, boolean):
  2.     mask = 0x1 << bit_number
  3.     return integer | mask if boolean else integer & ~mask
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand