Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //returns the bit value of n on the p position
- int seeBit(int n, unsigned int p)
- {
- //n(2) = Bn/Bn-1/Bn-2/.../B2/B1/B0
- if(n & (1 << p))
- return 1;
- else return 0;
- }
- //sets the p bit on or off
- void setBit(int *n, unsigned int p, unsigned int status)
- {
- if(status)
- *n |= (1 << p);
- else
- *n &= ~(1 << p);
- }
- //negates the p bit
- void invBit(int *n, unsigned int p)
- {
- (*n) ^= (1 << p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement