sep 23
Devin's take on problem 68. Does it work for n=32? Fix?
/* This function takes an int n as input and returns
a mask with the n least significant bits set to 1.
Example: n = 6 returns 0x2F.
*/
// We start with 0 and take its bitwise negation to receive
// a word with a 1 in every bit (this step is taken instead
// of using 0xFFFFFFFF to cover all possible word sizes).
// Shifting n times to the left creates a 0 in the first
// n bits. Taking the bitwise negation once again returns
// the word to zeroes with a 1 in the n least significant bits.
int loweronemask(unsigned n) {
return ~((~0x0) << n);
}
coming soon, for a midterm grade: CM bomblab.
Finish Tuesday's notes.
Then either :