4

If I type:

a=float(0)
b=float(-2)
a/b

I get:

-0.0

Is there a way to get rid of this minus? The reason I want to this is because when I run the doctest and the expected value is 0.0 and I get -0.0 it says that test is failed, although it says True when I type -0.0==0.0.

1 Answers1

9

You can pass the return value to abs to get its absolute value:

>>> a=float(0)
>>> b=float(-2)
>>> abs(a/b)
0.0
>>>