+ 2

C++ ??How to determine if two integers are equal without using camparison...

It has some banned keyword : define, include, using, if, ":", switch. You just can include <iostream>. Can you help me this homework. Thanks a lot.

9th Nov 2020, 9:52 AM
đỗ nam
đỗ nam - avatar
4 Answers
+ 5
The bitwise exclusive OR operator would only yield 0 if both operands are equal (you could also use a subtraction, but bitwise operations are cooler). https://www.sololearn.com/learn/4074/?ref=app Since 0 translates to false and every other value to true in a boolean sense, you can use the logical NOT operator to return true for equal values and false for all others.
9th Nov 2020, 10:41 AM
Shadow
Shadow - avatar
+ 3
Martin Taylor I wrote "exclusive OR" above, wouldn't that be equal to XOR in terms of meaning? Or am I mixing something up right now?
9th Nov 2020, 1:14 PM
Shadow
Shadow - avatar