1
0

fmaxl.c 410 B

123456789101112131415161718192021
  1. #include <math.h>
  2. #include <float.h>
  3. #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
  4. long double fmaxl(long double x, long double y)
  5. {
  6. return fmax(x, y);
  7. }
  8. #else
  9. long double fmaxl(long double x, long double y)
  10. {
  11. if (isnan(x))
  12. return y;
  13. if (isnan(y))
  14. return x;
  15. /* handle signed zeros, see C99 Annex F.9.9.2 */
  16. if (signbit(x) != signbit(y))
  17. return signbit(x) ? y : x;
  18. return x < y ? y : x;
  19. }
  20. #endif