How do you efficiently convert a number n to a number with that many low significant bits set? That is, for an 8-bit integer:
0 -> 00000000 1