Skip to content

Instantly share code, notes, and snippets.

View Mahedi-61's full-sized avatar
πŸ•Œ
Oh Lord! Bestow me with Knowledge

Md Mahedi Hasan Mahedi-61

πŸ•Œ
Oh Lord! Bestow me with Knowledge
View GitHub Profile
#Basic Tricks
Check if a number is odd/even
if ((n & 1) == 1) β†’ odd
if ((n & 1) == 0) β†’ even
Check if k-th bit is set
if ((n & (1 << k)) != 0) β†’ k-th bit is 1
Set the k-th bit
n | (1 << k)