Switch to unordered floating point compares.
In particular, this gives us desired behavior for NaNs (all compares involving a NaN evaluate to true). This in turn allows writing the canonical isnan() function as "v != v". Added isnan() to the standard library as well.
This commit is contained in:
@@ -10,7 +10,7 @@ export void f_v(uniform float RET[]) {
|
||||
h = float_to_half(f);
|
||||
|
||||
// may return a different value back for NaNs..
|
||||
if (f == f && i != h)
|
||||
if (!isnan(f) && i != h)
|
||||
++errors;
|
||||
}
|
||||
RET[programIndex] = errors;
|
||||
|
||||
@@ -9,7 +9,7 @@ export void f_v(uniform float RET[]) {
|
||||
float f = half_to_float(i);
|
||||
h = float_to_half(f);
|
||||
|
||||
int mismatches = (f == f && i != h);
|
||||
int mismatches = (!isnan(f) && i != h);
|
||||
if (any(mismatches != 0))
|
||||
print("mismatch: orig int16 % -> float % -> half %\n", i, f, h);
|
||||
errors += reduce_add(mismatches);
|
||||
|
||||
@@ -10,7 +10,7 @@ export void f_v(uniform float RET[]) {
|
||||
h = float_to_half(f);
|
||||
|
||||
// may return a different value back for NaNs..
|
||||
if (f == f && i != h)
|
||||
if (!isnan(f) && i != h)
|
||||
++errors;
|
||||
}
|
||||
RET[programIndex] = errors;
|
||||
|
||||
Reference in New Issue
Block a user