Skip to content

Instantly share code, notes, and snippets.

Last active Jun 7, 2016
What would you like to do?
The getbits() function in K&R (The C Programming Language, 2nd Edition)
/* 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