Hey all,
I'm working with floating points and I'm worried about equalities not triggering due to precision. This time around, I think I'm safe, but I don't know how/where to check. There are no calculations taking place; I need to know if assignment will always be precise with itself:
1 2 3 4 5 6 7
|
double checkValue(someErrorConstantDefinedElsewhere);
for (someMassiveAmountofIterations) {
if (someConditionFulfilled) {
checkValue = someCalculation();
}
}
if (checkValue != someErrorConstantDefinedElsewhere) { doSomething(); }
|
As you can see, the check can only trigger if NOTHING happened to checkValue, thus it still holds its original value, which was assigned directly from the control constant.
Will this always work, or will imprecisions sneak into the assignment and comparison too? According to my understanding of floating point
magicmath I would say it will be correct, but I also realize that this would be an incredibly annoying bug to track considering of its location and the results of the check triggering or not.
If it's not a straightforward answer, can someone point me to where I could find the info for my system & compiler?