On Feb 27, 4:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi, I have the following functions,  but ' dx = abs(i2 - i1)/min(i2,
> i1)' always return 0, can you please tell me how can i convert it from
> an integer to float?
>
> def compareValue(n1, n2):
>     i1 = int(n1)
>     i2 = int(n2)
>
>     dx = abs(i2 - i1)/min(i2, i1)
>     print dx
>     return dx < 0.05

dx = float(abs(i2 -i1))/min(i2, i1)

Or you could just put "from __future__ import division" at the top of
your file.

see http://www.python.org/dev/peps/pep-0238/ for details.

-Matt

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to