I'm programming a library with multiple instances of long mathematical formulas that sometimes underflow when using doubles. One example could be:
(Exp(-a*a) - Exp(-b*b))*Exp(c)*Exp(d)
And a,b,c,d also involve some computation of similar type. I can deal with doubles getting this wrong (and return appropriate error message or some analytical bound) but if I don't detect underflow (on the difference of exponentials for instance) it leads to behavior that I can't afford. (Both absolute and relative errors can be massive when this difference clips to zero while other exponentials are very large).
Is there something similar to checked keyword that works for doubles? Is there some way I can implement checks in an assisted way?
Any solution that makes sure it's correct, even one which raises more flags than necessary is good for me.
This question was suggested as a duplicate but 'manually check before every multiplication' is not a particularly usefull solution for me.