s_fdim.c 520 B

12345678910111213141516171819202122232425
  1. /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
  2. *
  3. * Permission to use, copy, modify, and distribute this software
  4. * is freely granted, provided that this notice is preserved.
  5. */
  6. #include "math.h"
  7. #include "math_private.h"
  8. libm_hidden_proto(fdim)
  9. #ifdef __STDC__
  10. double fdim(double x, double y)
  11. #else
  12. double fdim(x,y)
  13. double x;
  14. double y;
  15. #endif
  16. {
  17. int c = __fpclassify(x);
  18. if (c == FP_NAN || c == FP_INFINITE)
  19. return HUGE_VAL;
  20. return x > y ? x - y : 0.0;
  21. }
  22. libm_hidden_def(fdim)