3 ms·
I dislike the fact that NaN taints other numbers - for precisely the same reason. Much better, in terms of early failure, would be signalling NaN or something
by dllthomas 13y ago
I dislike the fact that NaN taints other numbers - for precisely the same reason.
Much better, in terms of early failure, would be signalling NaN or something like...
...
maybenan_double maybe_nan = 0.0 / 0.0;
double x = 1.0;
if(is_nan(maybe_nan)) {
fprintf(stderr, "maybe_nan is NaN\n");
return 1;
}
double not_nan = from_maybenan(maybe_nan);
double y = not_nan + x;
...
Of course, there are other dimensions in which this is not better, but I don't like silent propagation if it might stretch over a lot of code.