Add SetBit to bitmanipulation (#4348)

This commit is contained in:
Lukas
2023-09-06 16:46:45 +02:00
committed by GitHub
parent fc693e8b51
commit 29a864b5b3
2 changed files with 23 additions and 0 deletions

View 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);
}
}