![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | AfterCadaver |
Sometimes when I use round(), I get -0 because of division by negative integer. Does anyone know any quick and simple ways to get just 0 when doing this in general?
Can you give us an code example?
That smells like a bug. -0 is a surreal number that has not to exist.
juppi | 2020-06-27 10:51
One possible option is to use int(round(x))
instead of round(x)
.
For example, print(int(round(1.0/(-3))))
displays 0, whereas print(round(1.0/(-3)))
displays -0.
haydenv | 2020-06-27 13:33