This is the example in knr, which is what I have to presumeably adapt to the following:Code:/* getbits: get n bits from position p */
unsigned getbits(unsigned x, int p, int n)
{
return (x >> (p+1 -n)) & ~(0 << n);
}
Could someone please re-iterate this. Maybe draw a few diagrams to :pQuote:
Write a function getbits(x,p,n,y) that return x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.