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

Robert Helling helling at atdotde.de
Tue Mar 18 01:53:18 PDT 2014

On 18.03.2014, at 04:39, Dirk Hohndel <dirk at hohndel.org> wrote:


> 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Get-rid-of-division-by-0-by-reshuffling-EAD-and-EAN-.patch
Type: application/octet-stream
Size: 2373 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140318/ba419563/attachment.obj>
-------------- next part --------------

Robert C. Helling     Elite Master Course Theoretical and Mathematical Physics
                      Scientific Coordinator
                      Ludwig Maximilians Universitaet Muenchen, Dept. Physik
                      Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339

Enhance your privacy, use cryptography! My PGP keys have fingerprints
A9D1 A01D 13A5 31FA 6515  BB44 0820 367C 36BC 0C1D    and
DCED 37B6 251C 7861 270D  5613 95C7 9D32 9A8D 9B8F

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140318/ba419563/attachment.sig>

More information about the subsurface mailing list