/* * 5 0101 * 9 1010 * * 5 ^ 5 * 0101 * 0101 *-----* 0000 * Draw the first rule: the same number is different or, the result is 0 * * 9 ^ 5 ^ 6 * 1010 * 0101 *----* 1111 * * 1111 * 0110 *----* 1001 * * 9 ^ 6 ^ 5 * 1010 * 0110 *-----* 1100 * * 1100 * 0101 *-----* 1001 * Get a second rule: different Or the order can be exchanged * * 1001 * 0000 *----* 1001 * * 0101 * 0000 *----* 0101 * Get the third rule: any number and 0 XOR, the result is itself *///Law 1, the same number is different or, the result is 0// Rule 2, XOR order can be exchanged 9 ^ 5 ^ 6 = 9 ^ 6 ^ 5//Law 3, any number and 0 XOR, the result is itself//derivation a ^ b ^ a = b//According to 2 a ^ b ^ a = a ^ a ^ b//according to 1 a ^ B ^ a = a ^ a ^ b = 0 ^ b//According to 3 a ^ b ^ a = a ^ a ^ b = 0 ^ b = becho Php_eol;function swap ($a, $b) { $a ^= $b;
// A = (a ^ b); $b ^= $a; b = (a ^ b) ^ B; The result is B = a $a ^= $b; A = (a ^ b) ^ (a ^ b ^ b); Two a merges to 0, two B merges to 0, and finally B, and the result is a = B echo $a. $b; Swap (1, 2);
The above describes the different or operation deduction, Exchange data, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.