0
Know if number is odd or even without using the modulus operator?
I have an int a = 17; I want to know if the nunber is odd or even WITHOUT the modulus operator.
2 Answers
+ 1
int b =aĂ·2
if bĂ2==a
a is even
else a is odd
+ 1
bool isOdd = a & 1;
I have an int a = 17; I want to know if the nunber is odd or even WITHOUT the modulus operator.