array precision

Hugo Martires hugomartires at hotmail.com
Tue Feb 5 12:33:43 EST 2002


Hellow every one !
I'm using the array module to create a simple array:

myArray = array.array('f', [0.5, 0.5, 0.5, 0.5]

now i want to add to each position of the array the number:

myArray[i] = myArray[i] + (1.0/n)

suposing that n=10 we get: myArray[0] = 0.600000023 ("something like this")

but if i do: myArray[i] + (1.0/n) it give's me 0.6

what's the problem of the array, and how can i solve this ?

Tanks in advance !



More information about the Python-list mailing list