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);<
Here's a method that doesn't require any arithmetic:
~(~0u << n)