what does it means?
int myXor(int x, int y)
{
return (x | y) & (~x | ~y);
}
It is basically “^” operator defined using a function… I mean this function works as ^ operator for
int x and y in paramter
^ operator is bitwise XOR… It means ith bit of output integer is XOR of ith bit of x and ith bit of y in binary representation…
XOR is a binary function which takes two parameters of one bit and returns 1 if both are different and returns zero if both are same… try searching exclusive-OR (XOR)
For example if x=5 and y=12 then x^y = myXor(x,y) = (…00101)^(…01100)
Where …00101 and …01100 are binary representation of 5 and 4 respectively…
= (…01001) = 9
Where 01001 in binary is equivalent to 9 in decimal… hence function will return 9…
5^12 would also give the same output…