def generate_offset6(value):
    """Returns the 6-bit two's complement representation of the number."""
    if value < 0:
        # the sign bit needs to be bit number 6.
        return 0x1 << 5 | (0b11111 & value)
    else:
        return value