[PATCH] Don't calculate with NaN when on 100% o2

Dirk Hohndel dirk at hohndel.org
Sun Mar 30 14:07:33 PDT 2014


On Tue, 2014-03-18 at 09:53 +0100, Robert Helling wrote:
> On 18.03.2014, at 04:39, Dirk Hohndel <dirk at hohndel.org> wrote:
> 
> Guys,
> 
> > I really don't want Anton's patch. Linus hasn't submitted a better
> > patch. I could just take both of them and merge them.
> > 
> > The choices, the choices...
> 
> maybe it’s a good idea to take a step back. Often enough, when encountering things like division by 0 this is not a random bug but it actually means something (possibly that you are trying to calculate something non-sensical). Alternatively we might be computing stuff in a weird way (for example such that we end up both multiplying and dividing by zero).
> 
> Here is a third patch that reshuffles the logic for computing EAD and END and thus gets rid of the problematic intermediate variable ratio and never divides by anything that could be potentially 0. IMHO the new expressions are simpler than the old ones.
> 
> I have a request though: Please check the math before applying (I think I had it wrong in a first go, just too early in the morning for me). I tried to insert type casts to double and explicit float constants to make divisions floating point so we don’t get stuck with integer division rounding errors but please check also that I did not miss anything.
> 

Tried to talk to you on IRC, but let's repeat here:

+		entry->ead = (entry->depth + 10000) * (1000 - fhe) / 1000.0 - 10000;
+		entry->end = (entry->depth + 10000) * (1000 - fo2 - fhe) / (double)N2_IN_AIR - 10000;

That first one is the definition of END, the second one the definition
of EAD. What am I missing?

/D



More information about the subsurface mailing list