Ragib Asif

Software Engineer, Mathematician, Writer, Artist, Poet

← Back to all posts

Clear the Lowest Set Bit

To “clear the lowest set bit” means turn the lowest bit with a value of 1 to a value of 0. The formula is n & (n - 1).

This is also used to check if a number is a power of 2. If a number is a power of 2, then performing n & (n - 1) will return 0.