tests: Normalise NAN values in compare_float() and compare_double().

I.e., ignore the mantissa/payload of NAN values.
This commit is contained in:
Petrichor Park
2024-08-22 09:12:01 -05:00
committed by Henri Verbeet
parent a083748626
commit 0b8abe754a
Notes: Henri Verbeet 2025-08-21 16:34:21 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1000

View File

@@ -42,6 +42,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#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;