SHARE
TWEET

Untitled

a guest Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def be_to_le(value: int) -> int:
  2.     assert isinstance(value, int)
  3.     numbytes = len(f"0{value:x}") >> 1
  4.     if numbytes == 1:
  5.         return value
  6.     rslt = 0
  7.     for b in value.to_bytes(numbytes, byteorder="little"):
  8.         rslt <<= 8
  9.         rslt |= b
  10.     return rslt
  11.      
  12. numbytes = math.ceil(value.bit_length() / 8)
  13.      
  14. def be_to_le(value: int) -> int:
  15.     numbytes = math.ceil(value.bit_length() / 8)
  16.     return int.from_bytes(value.to_bytes(numbytes, byteorder="little"), byteorder="big")
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top