MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / getIthBit

Function getIthBit

CPP/bitmasking/bit-functions.cpp:8–11  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#define mod 1000000007
7#define endl '\n'
8int getIthBit(int n,int i){
9 int mask=(1<<i);
10 return (n&mask)>0 ? 1:0;
11}
12void setIthBit(int &n,int i){
13 int mask=(1<<i);
14 n=(n|mask);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected