Need help understanding “getbits()” method in Chapter 2 of K&R C
Let’s use 16 bits for our example. In that case, ~0 is equal to 1111111111111111 When we left-shift this n bits (3 in your case), we get: 1111111111111000 because the 1s at the left are discarded and 0s are fed in at the right. Then re-complementing it gives: 0000000000000111 so it’s just a clever way … Read more