Cygwin: pinfo: use stpcpy where appropriate
[newlib-cygwin.git] / winsup / cygwin / math / fdiml.c
blob3be0679acd50397d286723195ee24421e3f9fa07
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6 #include <errno.h>
7 #include <math.h>
9 long double
10 fdiml (long double x, long double y)
12 int cx = fpclassify (x), cy = fpclassify (y);
13 long double r;
15 if (cx == FP_NAN || cy == FP_NAN
16 || (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
17 return x - y; /* Take care invalid flag is raised. */
18 if (x <= y)
19 return 0.0;
20 r = x - y;
21 if (fpclassify (r) == FP_INFINITE)
22 errno = ERANGE;
23 return r;