7. First Set bit #

Created Tuesday 30 June 2020

e.g 101010100 ⇒ 100

We don’t now where the first 1 is, do manips, and we don’t

n =    101010100
n-1;// 101010011 // useless
-n; // 010101101
n & -n

Turn off first set bit

n =    101010100
n-1;// 101010011
n & (n-1);// nothing was affected on the left