Question DSA-BIT-0072
HardHow do you set all bits below and including the lowest set bit? (for n = 12, giving 15)
- A.
n | (n − 1)
- B.
n >> 1
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Bit Manipulation question
How do you set all bits below and including the lowest set bit? (for n = 12, giving 15)
n | (n − 1)
n >> 1
Sign up free to see the answer and a step-by-step explanation.
n ^ n
n & (n − 1)