def signFix(val, width):
    """
    Convert negative int to positive int which has same bits set
    """
    if val > 0:
        msb = 1 << (width - 1)
        if val & msb:
            val -= mask(width) + 1
    return val
def signFix ( val , width ) : if val > 0 : msb = 1 << ( width - 1 ) if val & msb : val -= mask ( width ) + 1 return val
Convert negative int to positive int which has same bits set