Bits
Bit Masks and Bit Extraction
In this question, we will write helper functions for working with groups of bits inside a 32-bit unsigned integer.
A mask is an integer whose bits are used to select part of another integer. For example, the mask for the lower 5 bits is:
00000000 00000000 00000000 00011111
which is 0x0000001f.
For this question, assume that num_bits and offset are chosen so that the requested bits fit within a 32-bit value. In other words, you do not need to handle cases like asking for 40 bits or asking for 8 bits starting at offset 30.
(When logged in, completion status appears here.)