Bitwise Snippets

Bitwise operations are fun, but hard to remember...

Published over 2 years ago · Last edited over 2 years ago · 1 min read

...and since they're so hard, I've decided to write them here as I learn.

Know some that are missing here? Let me know on twitter

isOdd implementation

Happens that you can check if a value is odd or not by shifting it 1 bit and checking if the result is 0 or 1.

In case the result is 0, then it means the given number is an odd number.

export const isOdd = (num: number) => Boolean(num & 0x01);