Originally Posted by
Yabssato
That was pretty confusing.
Do it longhand ... pencil and paper
PHP Code:
4 = 00000100
5 = 00000100
Not 4 = 11111011 (~ operator)
And 5 00000101 (& operator)
========
00000001
4 = 00000100
xor 5 00000101
========
00000001
Same answer...
here is the function, i am supposed to change the return to make it work
Code:
/* * bitXor - x^y using only ~ and &
* Example: bitXor(4, 5) = 1
* Legal ops: ~ &
* Max ops: 14
* Rating: 1
*/
int bitXor(int x, int y) {
return (~x) & y;
}