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

Method getIthBit

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

Source from the content-addressed store, hash-verified

1public class BitOperations {
2 //Get ith Bit
3 public static int getIthBit(int n, int i) {
4 int bitMask = 1<<i;
5 return (n & bitMask) == 0 ? 0 : 1;
6 }
7
8 //Set ith Bit
9 public static int setIthBit(int n, int i) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected