Skip to content

Instantly share code, notes, and snippets.

@makamaka
Created September 17, 2010 10:23
Show Gist options
  • Save makamaka/584028 to your computer and use it in GitHub Desktop.
Save makamaka/584028 to your computer and use it in GitHub Desktop.
for q/Q options unsupported pack
sub unpack_Q {
my ( $v1, $v2 ) = unpack( 'N2', shift );
return $v1 * (2 ** 32) + $v2;
};
sub unpack_q {
my $v = shift;
my ( $v1, $v2 ) = unpack( 'N2', $v );
return $v1 * (2 ** 32) + $v2 if $v1 < 0xf0000000;
$v = ~$v;
( $v1, $v2 ) = unpack( 'N2', $v );
return ($v1 * (2 ** 32) + $v2 + 1 ) * -1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment