MCPcopy Create free account
hub / github.com/apna-college/Alpha / clearBitsinRange

Method clearBitsinRange

5_Bit Manipulation/BitOperations.java:42–47  ·  view source on GitHub ↗
(int n, int i, int j)

Source from the content-addressed store, hash-verified

40
41 //Clear Bits in Range (i,j)
42 public static int clearBitsinRange(int n, int i, int j) {
43 int a = ~0<<i;
44 int b = (1<<i)-1;
45 int bitMask = a | b;
46 return n & bitMask;
47 }
48
49 //Check if number is power of 2 or not
50 public static boolean isPowerof2(int n) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected