1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. 2 * 3 * Permission to use, copy, modify, and distribute this software 4 * is freely granted, provided that this notice is preserved. 5 */ 6 7 #include "math.h" 8 #include "math_private.h" 9 #include <errno.h> 10 fdim(double x,double y)11double fdim(double x, double y) 12 { 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; 17 18 if (x <= y) 19 return .0; 20 21 double z = x - y; 22 if (isinf(z) && cx != FP_INFINITE && cy != FP_INFINITE) 23 __set_errno(ERANGE); 24 25 return z; 26 } 27 libm_hidden_def(fdim) 28