double comparisons not working correctly
Closed this issue · 1 comments
pkatta-ktc commented
Hello,
I am using double type in c++ for the attached variables Qty1, Qty2, & Qty3.
My expression is: "(Qty1-Qty2+Qty3) = 0 ? Qty1 * 2 : 0"
Mathematically "Qty1-Qty2+Qty3" is zero.
However, this is getting hit by the usual double precision issues. Within muParser when it does the operations "Qty1-Qty2+Qty3" because of how double's behave, the "=" comparison is not working properly.
Outside of muParser I would use arbitrary precision types. How can I ensure proper comparisons within muParser?
Thanks.
beltoforion commented
There is currently no solution for that. It could be fixed easily by changing the implementations of equal and not equals operators to use the usual workaround with fabs and a delta value comparison.