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);
1.4m articles
1.4m replys
5 comments
57.0k users