mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 10:15:51 +08:00
Add SetBit to bitmanipulation (#4348)
This commit is contained in:
10
src/main/java/com/thealgorithms/bitmanipulation/SetBit.java
Normal file
10
src/main/java/com/thealgorithms/bitmanipulation/SetBit.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
/**
|
||||
* Sets a specific bit to 1
|
||||
*/
|
||||
|
||||
public class SetBit {
|
||||
public static int setBit(int num, int bit) {
|
||||
return num | (1 << bit);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user