in reply to Re^2: Hexadecimal Exclusive OR
in thread Hexadecimal Exclusive OR

use bignum:
use bignum; my $var1 = 0x0000805063008357 ; my $var2 = 0x042426FFFFFFFFFF ; my $result = $var1 ^ $var2; printf "0x%016x\n",$result;
Gives:
0x00000000ffffffff
Which goes to show that printf does not support big ints.
Update: improved printf

Replies are listed 'Best First'.
Re^4: Hexadecimal Exclusive OR
by almut (Canon) on Jun 16, 2010 at 14:36 UTC
    Which goes to show that printf does not support big ints.

    You could write

    print $result->as_hex();

    because, with the bignum pragma in effect, the numbers are upgraded to Math::BigInt objects which have the as_hex() method (among others).

    And to get rid of the "Hexadecimal number > 0xffffffff non-portable" warning, you could say

    my $var1 = hex("0x0000805063008357");

    (hex() would need to be imported for perls before 5.9.4)