how to convert an integer to a float?

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Tue Feb 27 19:19:57 EST 2007


yinglcs at gmail.com wrote:

> def compareValue(n1, n2):
>     i1 = int(n1)
>     i2 = int(n2)
> 
>     dx = abs(i2 - i1)/min(i2, i1)
>     print dx
>     return dx < 0.05

You could also prepend 

from __future__ import division

Regards,


Björn

-- 
BOFH excuse #237:

Plate voltage too low on demodulator tube




More information about the Python-list mailing list