brisk man brisk man - 2 months ago 9
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 
}
Comments