python how to grab the last bit of an 8bit code example Example: keep last n bits unsigned mask; mask = (1 << n) - 1; unsigned lastNbits = value & mask;