def _trailing_zeros(value, bit_width=8):
    """Count trailing zeros on a binary number with a given bit_width

    ie: 0b11000 = 3

    Used for shifting around values after masking.
    """
    count = 0
    for _ in range(bit_width):
        if value & 1:
            return count
        count += 1
        value >>= 1
    return count