brisk man brisk man - 6 months ago 36
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

In C (and most C-like languages)

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