Using only bitwise operators (|, &, ~, ^, >>, <<) and other basic operators like +, -, and !, is it possible to replace the "==" below?
int equal(int x, int y) { return x == y; }
Remember that an XOR is the exactly same as NOT EQUALS and XNOR is exactly the same as EQUALS. So, the following will give you exactly what you want:
XOR
NOT EQUALS
XNOR
EQUALS
return !(x ^ y);
2.1m questions
2.1m answers
60 comments
57.0k users