How to set (in most elegant way) exactly n least significant bits of uint32_t? That is to write a function void setbits(uint32_t *x, int n);<
n
uint32_t
void setbits(uint32_t *x, int n);<
If you mean the most significant n bits:
-1 ^ ((1 << (32 - n)) - 1)