double fmax(double x, double y) { if (x.isNaN) return y; if (y.isNaN) return x; return x > y ? x : y; }