Loss of precision with very small numbers in Python arrays

I have two arrays of type float64, and when I assign the value of the first to the second, it rounds the value. The following simple code illustrates the problem and eliminates the possibility of simply representing numbers. (I schematized a snippet of my code to be more readable, but essentially the same thing)

X = zeros((2,2))
Y = zeros((2,2))
Z = X            #a shorter way of making a new matrix, equal to X...
X[0,0] = Y[0,0]
Z[0,0]=0
print Y[0,0]
print X[0,0]
print type(Y[0,0])
print type(X[0,0])
if X[0,0]==Y[0,0]:
   print'they are equal'
else:
   print'they are NOT equal'

I executed this small code snippet for all coefficients, and all outputs look like this:

1.90897e-14
0
<type 'numpy.float64'>
<type 'numpy.float64'>
they are NOT equal

It seems to me that the X array is of a different type, but it is created in the same way, with the zeros () function with the standard type (float64)

Edit: arrays are initialized with

X = zeros((2,2), dtype=float64)
Y = zeros((2,2), dtype=float64)

An additional useful fingerprint has also been added to the above example.

Edit: added problem lines after I found the problem

+5
1

, X float64? , , X [0,0] 0.0, 0, .

>>> Xf = arange(10,dtype=float64)
>>> Xi = arange(10)
>>> Xf[0]
0.0
>>> Xi[0]
0
>>> Yf = Xf*0.0
>>> Yf[0]
0.0
>>> 
>>> Yf[0] = 1.90897e-14
>>> Yf[0]
1.9089700000000001e-14
>>> Xf[0] = Yf[0]
>>> Xf[0]
1.9089700000000001e-14
>>> Xi[0] = Yf[0]
>>> Xi[0]
0
+3

All Articles