In Python, if you calculate 0 ÷ negative numbers, the result will be -0.0
.
n = 0.0/-1
print(n)
# =>-0.0
You can remove the sign of -0.0
by adding 0.0
.
n = 0.0/-1
print(n+0.)
# => 0.0
I have encountered this phenomenon in AOJ Question 0004 and have had trouble. I hope it helps people who are in trouble with minus zero.
Recommended Posts