boolean xnor(boolean a, boolean b) {
return !(a ^ b);
}
or even simpler:
boolean xnor(boolean a, boolean b) {
return a == b;
}
If you are actually talking about bitwise operators (you say you’re operating on int
), then you will need a variant of the first snippet:
int xnor(int a, int b) {
return ~(a ^ b);
}