how to convert an integer to a float?
Grant Edwards
grante at visi.com
Tue Feb 27 19:39:19 EST 2007
On 2007-02-28, jeff <jeffrey.aylesworth at gmail.com> wrote:
> On Feb 27, 7:05 pm, "ying... at gmail.com" <ying... at gmail.com> 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
>
> x = x + 0.0
How, um, perlesque.
I rather think that this is a bit more pythonic:
x = float(x)
--
Grant Edwards grante Yow! I'm a fuschia bowling
at ball somewhere in Brittany
visi.com
More information about the Python-list
mailing list