/* Return positive difference between arguments.
- Copyright (C) 1997, 2004, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
int clsx = fpclassify (x);
int clsy = fpclassify (y);
- if (clsx == FP_NAN || clsy == FP_NAN
- || (y < 0 && clsx == FP_INFINITE && clsy == FP_INFINITE))
- /* Raise invalid flag. */
+ if (clsx == FP_NAN || clsy == FP_NAN)
+ /* Raise invalid flag for signaling but not quiet NaN. */
return x - y;
if (x <= y)
return 0.0;
double r = x - y;
- if (fpclassify (r) == FP_INFINITE)
+ if (fpclassify (r) == FP_INFINITE
+ && clsx != FP_INFINITE && clsy != FP_INFINITE)
__set_errno (ERANGE);
return r;