mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 02:04:31 +08:00
Add Clear Bit (#4355)
This commit is contained in:
@ -0,0 +1,11 @@
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
/**
|
||||
* Clears the bit located at clear from num
|
||||
*/
|
||||
|
||||
public class ClearBit {
|
||||
public static int clearBit(int num, int clear) {
|
||||
int mask = ~(1 << clear);
|
||||
return num & mask;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user