Bit-level operations – check integer is even or odd

In this short article I will exaplain how to use bit-level operations to verify that integer is even or odd. It’s very useful and fast verification. Examples below have been compiled and tested using gnu-gcc. $/> gcc example.c -o example CHECK EVEN To verify that integer is even we need to check first bit is not set. #include <stdint.h> #include <assert.h> … Read more