I was facing this unique problem of generating a bit-mask based on the input parameter. For example,
if param = 2, then the mask will be 0x3 (11b) if param = 5, then the mask will be 0x1F (1 1111b)
This I implemented using a for-loop in C, something like
int nMask = 0;
for (int i = 0; i < param; i ++) {
nMask |= (1 << i);
}
I would like to know if there is a better algorithm ~~~