Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def signed_to_unsigned(value, bit_count):
- return value & ((1 << bit_count) - 1)
- def unsigned_to_signed(value, bit_count):
- value = signed_to_unsigned(value, bit_count)
- if value & (1 << (bit_count - 1)):
- value -= (1 << bit_count)
- return value
Advertisement