c++ - can I check if a number is odd or even by using add and subract instructions only? -
can check if number or odd using add , subtraction. can subtract number until 2 or 1 can without that. can use neighboring numbers see if number odd or even
thanks
okay, you're not specifying operators can use, since mentioned in 1 comment abhor division , modulo, propose this:
if ((number & 1) == 0) { // } else { // odd }
Comments
Post a Comment