Skip to content

Instantly share code, notes, and snippets.

@aar0nTw
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aar0nTw/ca1953f2502088499ab6 to your computer and use it in GitHub Desktop.
Save aar0nTw/ca1953f2502088499ab6 to your computer and use it in GitHub Desktop.
length = 32
mid = 2**(length-1)
max_unsigned = 2**length
to_signed = proc {|n| (n>=mid) ? n - max_unsigned : n}
p to_signed["0xFFF54006".to_i(16)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment