brisk man brisk man - 1 year ago 62
C Question

How do I check if an integer is even or odd using bitwise operators

How do I check if an integer is even or odd using bitwise operators

Answer Source

In C (and most C-like languages)

if (number & 1) {
  // It's odd 
}