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 0977f08 commit ecd9475Copy full SHA for ecd9475
src/me/ramswaroop/bits/SubBit.java
@@ -19,12 +19,11 @@ public class SubBit {
19
* @return
20
*/
21
public static int getSubBits(int num, int start, int end) {
22
- num <<= (32 - end);
23
- num >>>= (start - end + 31); // more intuitive (start - 1 + 32 - end)
+ num = num << (32 - end) >>> (start - end + 31); // more intuitive (start - 1 + 32 - end)
24
return num;
25
}
26
27
public static void main(String a[]) {
28
- System.out.println(getSubBits(15, 1, 2));
+ System.out.println(getSubBits(5, 1, 2));
29
30
0 commit comments