This is basically just repr numpy arrays that are fooling you.
Consider the above example:
import numpy as np x = float(1) - np.array([1e-10, 1e-5]) print x print x[0] print x[0] == 1.0
This gives:
[ 1. 0.99999 ] 0.99999999999 False
So, the first element is actually non-zero, it is just a beautiful print of numpy arrays that show it this way.
This can be controlled using numpy.set_printoptions .
Of course, numpy is funded using limited precision floats. The entire numpy point must be a memory container for arrays of similar data, so there is no equivalent to the decimal class in numpy.
However, 64-bit floats have a decent accuracy range. You will not encounter many problems with 1e-10 and 1e-5. If you need to, there is also a numpy.float128 dtype, but operations will be much slower than using your own floats.
source share