Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cotto
Created July 26, 2011 08:31
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 cotto/1106278 to your computer and use it in GitHub Desktop.
Save cotto/1106278 to your computer and use it in GitHub Desktop.
fun with pack and unpack
perl -e 'print unpack("i", pack("i", -2315606021))."\n";'
x64: 1979361275
x86: -2147483648
perl -e 'print unpack("i", pack("i", -2315606022))."\n";'
x64: 1979361274
x86: -2147483648
What I need is something to chop off anything after 4 bytes. Actually, that's a lie. What I actually need is to know that the value will fit within the range of an int32.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment