def sign_extending(value, bit_width):
    if (value & (1 << (bit_width - 1))):
        return (value - (1 << bit_width))
    return value
def sign_extending(value, bit_width):
    if (value & (1 << (bit_width - 1))):
        return (value - (1 << bit_width))
    return value