From: Martin Taibr Date: Sun, 29 Sep 2019 10:26:43 +0000 (+0200) Subject: fix isnan X-Git-Tag: xonotic-v0.8.5~1255 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=16225fa152cd4b9bd9d663b9538989bd3f789999;p=xonotic%2Fxonotic-data.pk3dir.git fix isnan --- diff --git a/qcsrc/lib/warpzone/mathlib.qc b/qcsrc/lib/warpzone/mathlib.qc index 9105269ff..cf86d97f9 100644 --- a/qcsrc/lib/warpzone/mathlib.qc +++ b/qcsrc/lib/warpzone/mathlib.qc @@ -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) {