Possible Duplicate:
Python rounding error with float numbers
I created an array with numpy as a = numpy.arange(0,1e5,1,dtype=int)
. a[18645]
is 18645 as expected. When I create another array b=a*10e-15
, b[18645]
is 186.4999999999e-12. b[18644]
is 186.44e-12. Why does Python create these trailing 9s?
This issue came up when I was trying to search for an element in the array with numpy.where
. With the trailing 9s, the numpy.where
function failed to find 184.45e-12 in b
.