다른 언어들과 계산값이 다른 경우

반올림

원래 값 1.5 0.5 -0.5 -1.5
Rounding half up (사사오입)2.01.00.0-1.0
Rounding half down1.00.0-1.0-2.0
Rounding half toward zero1.00.00.0-1.0
Rounding half away from zero (cpp 기본방식)2.01.0-1.0-2.0
Rounding half to even (Python 기본방식)2.00.00.02.0
Rounding half to odd1.01.0-1.0-1.0

def round_half_up(x):
    if x > 0:
        return int(x) + 1 if x - int(x) >= 0.5 else int(x)
    else:
        return int(x) - 1 if int(x) - x >= 0.5 else int(x)