I am encountering an issue with this specific function implementation.
Calculations.add(this, //CONTEXT
function () { //CALUCATE
this.position.x += (this.movementSpeed.x / 10);
},
function () { //HAVE CALCULATED
return (this.position.x === (tempX + this.movementSpeed.x));
}
);
The problem arises when running the result as sometimes it produces incorrect outcomes. I expect that after 10 calculations, the HAVE CALCULATED
condition should be true.
However, there are instances where this is not the case and it negatively impacts my application functionality.
For example, if the expected result is 138, sometimes the calculation yields 138.000000000006 which causes the HAVE CALCULATED
check to fail.
I am struggling to find a solution to ensure accurate results. Using rounding functions is not an option as the output needs to reflect decimal values accurately.
Your assistance in solving this problem would be greatly appreciated.