mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 05:59:22 +08:00
12 lines
253 B
Java
12 lines
253 B
Java
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;
|
|
}
|
|
}
|