master
 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>
 8
 9long double
10fdiml (long double x, long double y)
11{
12  int cx = fpclassify (x), cy = fpclassify (y);
13  long double r;
14
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;
24}