[Solved] PHP XOR operation two numbers


That is because you re hitting the MAXIMUM INTEGER LIMIT which is 2147483647

From the PHP Docs…

The maximum value depends on the system. 32 bit systems have a maximum
signed integer range of -2147483648 to 2147483647. So for example on
such a system, intval(‘1000000000000’) will return 2147483647. The
maximum signed integer value for 64 bit systems is
9223372036854775807.

Thus to handle such big integers you need to make use of an extension like (GMP) GNU Multiple Precision

<?php
$v1="6463334891";
$v2="1000212390";
$a = gmp_init($v1);
$b = gmp_init($v2);
echo gmp_intval($a) ^ gmp_intval($b); //"prints" 7426059853

Else , Switch to a 64-bit system.

solved PHP XOR operation two numbers