We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06f9eca commit 44308e7Copy full SHA for 44308e7
src/main/java/com/thealgorithms/bitmanipulation/HigherLowerPowerOfTwo.java
@@ -27,7 +27,9 @@ private HigherLowerPowerOfTwo() {
27
* @return The next higher power of two.
28
*/
29
public static int nextHigherPowerOfTwo(int x) {
30
- if (x < 1) return 1;
+ if (x < 1) {
31
+ return 1;
32
+ }
33
x--;
34
x |= x >> 1;
35
x |= x >> 2;
@@ -44,7 +46,9 @@ public static int nextHigherPowerOfTwo(int x) {
44
46
* @return The next lower power of two.
45
47
48
public static int nextLowerPowerOfTwo(int x) {
- if (x < 1) return 0;
49
50
+ return 0;
51
52
return Integer.highestOneBit(x);
53
}
54
0 commit comments