Skip to content

Commit 4d237de

Browse files
author
prayas7102
committed
clang format changes (added author and hide default constructor)
1 parent eff83ce commit 4d237de

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
package com.thealgorithms.bitmanipulation;
22

3-
public class LowestSetBit {
3+
/**
4+
* Lowest Set Bit
5+
* @author Prayas Kumar (https://github.com/prayas7102)
6+
*/
47

8+
public class LowestSetBit {
9+
// Private constructor to hide the default public one
10+
private LowestSetBit() {
11+
}
512
/**
6-
* Isolates the lowest set bit of the given number. For example, if n = 18 (binary: 10010),
7-
* the result will be 2 (binary: 00010).
13+
* Isolates the lowest set bit of the given number. For example, if n = 18
14+
* (binary: 10010), the result will be 2 (binary: 00010).
815
*
916
* @param n the number whose lowest set bit will be isolated
1017
* @return the isolated lowest set bit of n
1118
*/
1219
public static int isolateLowestSetBit(int n) {
20+
// Isolate the lowest set bit using n & -n
1321
return n & -n;
1422
}
15-
}
23+
}

src/test/java/com/thealgorithms/bitmanipulation/LowestSetBitTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
import org.junit.jupiter.api.Test;
66

7+
/**
8+
* Test case for Lowest Set Bit
9+
* @author Prayas Kumar (https://github.com/prayas7102)
10+
*/
11+
712
public class LowestSetBitTest {
813

914
@Test
@@ -47,4 +52,4 @@ void testLowestSetBitWithLargeNumber() {
4752
// Test with a large number
4853
assertEquals(64, LowestSetBit.isolateLowestSetBit(448)); // 448 in binary: 111000000, lowest bit is 64
4954
}
50-
}
55+
}

0 commit comments

Comments
 (0)