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

Those hex constants represent 64-bit integers. You are using a version of Perl that can only handle 32-bit integers.

Several possibilities exist.

  1. Upgrade to a 64-bit Perl:
    $var1 = 0x0000805063008357 ;; Hexadecimal number > 0xffffffff non-portable at ( $var2 = 0x042426FFFFFFFFFF;; Hexadecimal number > 0xffffffff non-portable at ( printf "0x%0x\n", $var1 ^ $var2;; 0x424a6af9cff7ca8

    The non-portable warnings are just a stupid annoyance that can be suppressed.

  2. Manipulate the hex values as strings:
    $str2 = '042426FFFFFFFFFF';; $str1 = '0000805063008357';; print unpack 'H*', pack( 'H*', $str1 ) ^ pack('H*', $str2 );; 0424a6af9cff7ca8

    Whether that is useful will depend on how you are going to utilise the result?

  3. (Re-)compile your 32-bit version of Perl with use64bitint=define.

    That allows a 32-bit perl to manipulate 64-bit numbers, though you'd probably get those annoying 'non-portable' warnings.

As always, the right solution for your purpose will depend heavily upon that purpose?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy