add missing include to quieten compiler
[uclibc-ng.git] / libm / s_fdim.c
blob6ed695c3d755551b509e18d2ef7d27c345297aef
1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
7 #include "math.h"
8 #include "math_private.h"
9 #include <errno.h>
11 double fdim(double x, double y)
13 int cx = __fpclassify(x); /* need both NAN and INF */
14 int cy = __fpclassify(y); /* need both NAN and INF */
15 if (cx == FP_NAN || cy == NAN)
16 return x - y;
18 if (x <= y)
19 return .0;
21 double z = x - y;
22 if (isinf(z) && cx != FP_INFINITE && cy != FP_INFINITE)
23 __set_errno(ERANGE);
25 return z;
27 libm_hidden_def(fdim)