1570af302Sopenharmony_ci#include <math.h> 2570af302Sopenharmony_ci 3570af302Sopenharmony_cidouble fmax(double x, double y) 4570af302Sopenharmony_ci{ 5570af302Sopenharmony_ci if (isnan(x)) 6570af302Sopenharmony_ci return y; 7570af302Sopenharmony_ci if (isnan(y)) 8570af302Sopenharmony_ci return x; 9570af302Sopenharmony_ci /* handle signed zeros, see C99 Annex F.9.9.2 */ 10570af302Sopenharmony_ci if (signbit(x) != signbit(y)) 11570af302Sopenharmony_ci return signbit(x) ? y : x; 12570af302Sopenharmony_ci return x < y ? y : x; 13570af302Sopenharmony_ci} 14