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