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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -