+ 1
Round problem
print(round(4.5)) print(round(3.5)) print(round(2.5)) print(round(1.5)) print(round(0.5)) print(round(-.05)) print(round(-1.5)) print(round(-2.5)) print(round(-3.5)) print(round(-4.5)) >>> 4 4 2 2 0 0 -2 -2 -4 -4 Why??? Why not 5 4 3 2 1 0 -1 -2 -3 -4 ?
1 Respuesta
+ 2
It's normal, python3 and some other langs like c# use "banker's rounding" (rounding to nearest even number) instead of normal math rounding.
But python2 use normal math rounding.