1#include <math.h>
2
3double fmax(double x, double y) {
4    if (isnan(x))
5        return y;
6    if (isnan(y))
7        return x;
8    /* handle signed zeros, see C99 Annex F.9.9.2 */
9    if (signbit(x) != signbit(y))
10        return signbit(x) ? y : x;
11    return x < y ? y : x;
12}
13