Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0977f08

Browse files
author
Ram swaroop
committed
sub bit - comments added
1 parent 91e45f3 commit 0977f08

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/me/ramswaroop/bits/SubBit.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public class SubBit {
1818
* @param end
1919
* @return
2020
*/
21-
public static int getSubBit(int num, int start, int end) {
21+
public static int getSubBits(int num, int start, int end) {
2222
num <<= (32 - end);
23-
num >>>= (start - end + 31);
23+
num >>>= (start - end + 31); // more intuitive (start - 1 + 32 - end)
2424
return num;
2525
}
2626

2727
public static void main(String a[]) {
28-
System.out.println(getSubBit(15, 1, 2));
28+
System.out.println(getSubBits(15, 1, 2));
2929
}
3030
}

0 commit comments

Comments
 (0)