Clear Bit
Learn Clear Bit (Bit Manipulation, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Turning OFF a Specific Bit To CLEAR bit i (force it to 0): AND the number with a mask that has a 0 at position i and 1s everywhere else - num & ~(1 << i) . AND-ing with 1 leaves a bit unchanged; AND-ing with 0 forces it to 0.