Feb 21, 2022
If you're checking if a number is even, here are two one-liners.
number % 2 == 0
not (number & 1)
The modulo version is commonly known. The bitwise version is less known but faster.
If you're checking if a number is even, here are two one-liners.
number % 2 == 0
not (number & 1)
The modulo version is commonly known. The bitwise version is less known but faster.
C.D. Reimer makes topical videos about comic cons, pop culture, Silicon Valley and technology on YouTube. https://www.youtube.com/cdreimer