Search code examples
phpbit-manipulationbitbitwise-xor

XOR ing 3 numbers in php 5.4


i have this first bit number

36700165

and i am trying to XOR these 3 bits out of that first number

117440512

im doing

$bit = 36700165 XOR 0x1000000 XOR 0x2000000 XOR 0x4000000;

but it is returning empty when it should be returning

3145733

EDIT: this gave me what i want, is there a better way?

$bit = 36700165 & ~ 0x1000000 & ~ 0x2000000 & ~ 0x4000000;
$bit = 36700165 & ~ 117440512;

Solution

  • $bit = 36700165 & ~ 0x1000000 & ~ 0x2000000 & ~ 0x4000000;
    $bit = 36700165 & ~ 117440512;