I am trying to convert some Java code to Python, but seem to be running into issues with floating point precision.
I am unable to change the Java code, so the solution needs to be in the Python.
Java code:
float Ax = -0.13044776f;
float Ay = -0.17653446f;
float Az = 9.8041935f;
final float Ex = -40.55481f;
final float Ey = -22.624207f;
final float Ez = -57.284546f;
float Hx = Ey * Az - Ez * Ay;
In Java Hx has a value of -231.9248
Python code:
Ax = -0.13044776
Ay = -0.17653446
Az = 9.8041935
Ex = -40.55481
Ey = -22.624207
Ez = -57.284546
Hx = float(Ey * Az - Ez * Ay)
In Python Hx has a value of -231.92479960650965
Why is there more points of precision in Python, and how can I replicate the Java behaviour?
doubleinstead offloat? AFAIK Python uses 64-bit precision floating point numbers