]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix isnan
authorMartin Taibr <taibr.martin@gmail.com>
Sun, 29 Sep 2019 10:26:43 +0000 (12:26 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sun, 29 Sep 2019 10:26:43 +0000 (12:26 +0200)
qcsrc/lib/warpzone/mathlib.qc

index 9105269ff32ebbc00d9c54e832557943412cedd4..cf86d97f9cb5e22e6a2123eaf6f7136630cd590e 100644 (file)
@@ -27,10 +27,13 @@ bool isnan(float e)
        // the sane way to detect NaN is broken because of a compiler bug
        // (works with constants but breaks when assigned to variables)
        // use conversion to string instead
-
        //float f = e;
        //return (e != f);
-       return ftos(e) == "-nan";
+
+       // Negative NaN ("-nan") is much more common but plain "nan" can be created by negating *some* -nans so we need to check both.
+       // DP's QCVM and GMQCC's QCVM behave differently - one needs ftos(-(0.0 / 0.0)), the other ftos(-sqrt(-1)).
+       string s = ftos(e);
+       return s == "nan" || s == "-nan";
 }
 bool isnormal(float e)
 {