bruteforce: Check both input values for nan (#2270)

This commit is contained in:
Sreelakshmi Haridas Maruthur
2025-02-18 21:51:36 -07:00
committed by GitHub
parent bdd0eb0b7e
commit 32361e1d89

View File

@@ -1641,6 +1641,7 @@ double reference_expm1(double x)
double reference_fmax(double x, double y) double reference_fmax(double x, double y)
{ {
if (isnan(y)) return x; if (isnan(y)) return x;
if (isnan(x)) return y;
return x >= y ? x : y; return x >= y ? x : y;
} }
@@ -1648,6 +1649,7 @@ double reference_fmax(double x, double y)
double reference_fmin(double x, double y) double reference_fmin(double x, double y)
{ {
if (isnan(y)) return x; if (isnan(y)) return x;
if (isnan(x)) return y;
return x <= y ? x : y; return x <= y ? x : y;
} }
@@ -3611,6 +3613,7 @@ long double reference_expm1l(long double x)
long double reference_fmaxl(long double x, long double y) long double reference_fmaxl(long double x, long double y)
{ {
if (isnan(y)) return x; if (isnan(y)) return x;
if (isnan(x)) return y;
return x >= y ? x : y; return x >= y ? x : y;
} }
@@ -3618,6 +3621,7 @@ long double reference_fmaxl(long double x, long double y)
long double reference_fminl(long double x, long double y) long double reference_fminl(long double x, long double y)
{ {
if (isnan(y)) return x; if (isnan(y)) return x;
if (isnan(x)) return y;
return x <= y ? x : y; return x <= y ? x : y;
} }