From 16225fa152cd4b9bd9d663b9538989bd3f789999 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Sun, 29 Sep 2019 12:26:43 +0200 Subject: [PATCH] fix isnan --- qcsrc/lib/warpzone/mathlib.qc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qcsrc/lib/warpzone/mathlib.qc b/qcsrc/lib/warpzone/mathlib.qc index 9105269ff3..cf86d97f9c 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) { -- 2.39.2