I'm wondering how I would be able to tell if an integer is even or odd, I know that if the least significant bit is 1 then it is odd but I don't know how to tell if the integer has this bit as a 1 or a 0.

Recommended Answers

All 2 Replies

Look at the bit-wise operations like "AND", "OR" and "XOR".

Pentium class processor also have BT (Bit Test) that is non destructive unlike Salem's examples.

bt      eax, 0

would test bit zero and return CY = 1 if set otherwise 0. Otherwise boolean operators like in the previous post are the best alternative or choice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.