File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
main/java/com/thealgorithms/bitmanipulation
test/java/com/thealgorithms/bitmanipulation Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
/**
5
5
* Find Highest Set Bit
6
+ *
7
+ * This function calculates the position (or index) of the highest set bit (the leftmost 1 bit)
8
+ * in a given binary number.
9
+ *
6
10
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
7
11
*/
8
12
13
+
9
14
public final class HighestSetBit {
10
15
private HighestSetBit () {
11
16
}
@@ -27,4 +32,4 @@ public final static Optional<Integer> findHighestSetBit(int num) {
27
32
28
33
return Optional .of (position - 1 );
29
34
}
30
- }
35
+ }
Original file line number Diff line number Diff line change @@ -34,4 +34,4 @@ void testHighestSetBit() {
34
34
assertEquals (9 , HighestSetBit .findHighestSetBit (512 ).get ());
35
35
assertThrows (IllegalArgumentException .class , () -> HighestSetBit .findHighestSetBit (-37 ));
36
36
}
37
- }
37
+ }
You can’t perform that action at this time.
0 commit comments