s_fdim.c 496 B

123456789101112131415161718192021222324
  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. #ifdef __STDC__
  9. double fdim(double x, double y)
  10. #else
  11. double fdim(x,y)
  12. double x;
  13. double y;
  14. #endif
  15. {
  16. int c = __fpclassify(x);
  17. if (c == FP_NAN || c == FP_INFINITE)
  18. return HUGE_VAL;
  19. return x > y ? x - y : 0.0;
  20. }
  21. libm_hidden_def(fdim)