Array and floating point

Jonathan Shan jonshan at winlab.rutgers.edu
Fri Aug 17 23:06:56 CEST 2007


Hello,

I'm experiencing a problem where the float being appended to the array
is not the same as the result of the appending.

>>> from array import *
>>> x = array('f')
>>> x.append(float("0.1"))
>>> x[0]
0.10000000149011612
>>> float("0.1")
0.10000000000000001

I'm expecting x[0] = 0.10000000000000001

Thanks
Jonathan Shan




More information about the Python-list mailing list