I have to calculate some simple mathematical expression, but when I do it in one row, the result always will be zero. But the correct result is obviously not zero. And its interesting but when I separate the parts of expression, I get the correct answer. Later I will divide with this result, so it should not be 0.
The expression is like this:
(X-X1)/(X2-X1)
In this case the delta: 0
double delta = (x - x1) / (x2 - x1);
But this way the delta will be correct:
double top = x - x1;
double bottom = x2 - x1;
double delta = top/bottom;
Do you have any idea, how could this happen?