-
-
Save rickymanning/660e9acf9504032b7feb9210917f1dd7 to your computer and use it in GitHub Desktop.
The getbits() function in K&R (The C Programming Language, 2nd Edition)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* getbits: get n bits from position p */ | |
unsigned getbits(unsigned x, int p, int n) | |
{ | |
return (x >> (p+1-n)) & ~(~0 << n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment