$ ./foo.pl A) 0xfffffc0123456789 (should be 0xfffffc0123456789) B) 0xfffffc0123456800 (should be 0xfffffc0123456789) C) 0xfffffc0123456789 (should be 0xfffffc0123456789) D) 0xfffffc0123456800 (should be 0xfffffc0123456788 or maybe 0xfffffc0123456790) E) 0x23456789 (should be 0x23456789) F) 0xfffffc01 (should be 0xfffffc01) G) Comparing 0xfffffc0123456789 to 0xfffffc0123456785: 1) 0 (should be 1) 2) 0 (should be -1) 3) 0 (should be 0) $ $ cat foo.pl #!/usr/local/bin/perl $a = 0xfffffc0123456789; printf "A) %#x (should be 0xfffffc0123456789)\n", $a; $str = "0xfffffc0123456789"; printf "B) %#x (should be 0xfffffc0123456789)\n", hex($str); $b = unpack "Q", (pack "L2", hex(substr($str, 10)), hex(substr($str, 2, 8))); printf "C) %#x (should be 0xfffffc0123456789)\n", $b; printf "D) %#x (should be 0xfffffc0123456788 or maybe 0xfffffc0123456790)\n", $a - 1; printf "E) %#x (should be 0x23456789)\n", $a & 0xffffffff; printf "F) %#x (should be 0xfffffc01)\n", $a >> 32; $b = 0xfffffc0123456785; printf "G) Comparing %#x to %#x:\n", $a, $b; printf " 1) %d (should be 1)\n", $a <=> $b; printf " 2) %d (should be -1)\n", $b <=> $a; printf " 3) %d (should be 0)\n", $a <=> $a; $