keep last n bits
snippet in c

keep last n bits

user1473

unsigned  mask;
mask = (1 << n) - 1;
unsigned lastNbits = value & mask;