I would like to create a macro or function1 mask(n) which given a number n returns an unsigned integer with its n least sig
mask(n)
n
Here's one that is portable and conditional-free:
unsigned long long mask(unsigned n) { assert (n <= sizeof(unsigned long long) * CHAR_BIT); return (1ULL << (n/2) << (n-(n/2))) - 1; }