From 0b8abe754aa96f4c03d911ea95bce8657600592f Mon Sep 17 00:00:00 2001 From: Petrichor Park Date: Thu, 22 Aug 2024 09:12:01 -0500 Subject: [PATCH] tests: Normalise NAN values in compare_float() and compare_double(). I.e., ignore the mantissa/payload of NAN values. --- tests/utils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/utils.h b/tests/utils.h index f217f335a..fba9a3ba9 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -42,6 +42,7 @@ #include #include #include +#include #include "vkd3d_test.h" #include "vkd3d_d3d12.h" #include "vkd3d_d3dcompiler.h" @@ -165,8 +166,13 @@ static bool compare_float(float f, float g, unsigned int ulps) u.f = f; x = u.i; + if (isnan(f)) + x = (x & 0xff800000) | 0x400000; + u.f = g; y = u.i; + if (isnan(g)) + y = (y & 0xff800000) | 0x400000; if (x < 0) x = INT_MIN - x; @@ -187,8 +193,13 @@ static bool compare_double(double f, double g, unsigned int ulps) u.f = f; x = u.i; + if (isnan(f)) + x = (x & 0xfff0000000000000ll) | 0x8000000000000ll; + u.f = g; y = u.i; + if (isnan(g)) + y = (y & 0xfff0000000000000ll) | 0x8000000000000ll; if (x < 0) x = INT64_MIN - x;