by now i read a lot about this theme, not just now, but now again... and i thought i understand the point, and for sure it is a little bit awkward that i have to ask this, but i lack a proper solution whit which i feel right and save.
I used numpy and dtype numpy.flaot64, which i understand as an double precision, just to prevent the usual floating-problem. But now by testing its just the same. I have some billions (really) of calculations to do, (a further point why i chose np) so speed is of the essence, and i dont want do np.round() every step in my calculations... what would be a accurate result, because i just have this 3digits after the point. You can argue of course, why not multiply it whit 1000, or 10000, problem solved and numpy does such a thing in an instant. but it will lead to more problems, in further calculations, since there are a lot more calculations afterwards. Lets see the problem:
a = np.array([[7.125], [5.233]], dtype=np.float64)
b = np.array([[7.124], [5.232]], dtype=np.float64)
c = a - b
print(repr(c))
array([[0.001000000000000334 ],
[0.0009999999999994458]])
easy enough!!! I need no explanation why this happens, i dont look for an workaround whit np.round() or tempering on np.set_printoptions(), which i know this wont change my data, but just the way i become presented it. I thought an numpy-64bit-double-precision (128 is sadly not possible because all the big processing i have to do happens on my flatmates Win-PC xD, and by now, i doubt it would solve my problem, but correct me if i am wrong!!!) which did not hold more than 10 digits ever, would be enough to do it precisely. look whats happen if i do this:
a = np.random.randint(1000, 1000000,(5, 2))
b = np.random.randint(1000, 1000000,(5, 2))
a = a / 1000
b = b / 1000
c = a - b
print(a.dtype)
print(c)
>>>float64
[[ 375.929 -833.91 ]
[ 482.509 -106.411]
[ -2.08 -64.672]
[ 395.236 -383.997]
[ 213.829 -101.08 ]]
no such precision "collapse" thats what i would like.
So is there a "right" way to do it???
Thanks to listen to my story^^ and sorry to bring this problem to the table again^^
best regards