summaryrefslogtreecommitdiff
path: root/libquadmath/math/fdimq.c
diff options
context:
space:
mode:
Diffstat (limited to 'libquadmath/math/fdimq.c')
-rw-r--r--libquadmath/math/fdimq.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/libquadmath/math/fdimq.c b/libquadmath/math/fdimq.c
index 539fb08c641..501e9169520 100644
--- a/libquadmath/math/fdimq.c
+++ b/libquadmath/math/fdimq.c
@@ -1,5 +1,5 @@
/* Return positive difference between arguments.
- Copyright (C) 1997, 2004, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -14,29 +14,19 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include "quadmath-imp.h"
__float128
fdimq (__float128 x, __float128 y)
{
- int clsx = fpclassifyq (x);
- int clsy = fpclassifyq (y);
+ if (__builtin_islessequal (x, y))
+ return 0;
- if (clsx == QUADFP_NAN || clsy == QUADFP_NAN
- || (y < 0 && clsx == QUADFP_INFINITE && clsy == QUADFP_INFINITE))
- /* Raise invalid flag. */
- return x - y;
-
- if (x <= y)
- return 0.0Q;
-
- __float128 r = x - y;
- if (isinfq (r))
+ __float128 r = math_narrow_eval (x - y);
+ if (isinfq (r) && !isinfq (x) && !isinfq (y))
errno = ERANGE;
return r;