1 /* e_remainderl.c -- long double version of e_remainder.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid
[] = "$NetBSD: $";
21 /* __ieee754_remainderl(x,p)
23 * returns x REM p = x - [x/p]*p as if in infinite
24 * precise arithmetic, where [x/p] is the (infinite bit)
25 * integer nearest x/p (in half way case choose the even one).
27 * Based on fmod() return x-[x/p]chopped*p exactlp.
31 #include "math_private.h"
34 static const long double zero
= 0.0;
36 static long double zero
= 0.0;
41 long double __ieee754_remainderl(long double x
, long double p
)
43 long double __ieee754_remainderl(x
,p
)
47 u_int32_t sx
,sex
,sep
,x0
,x1
,p0
,p1
;
50 GET_LDOUBLE_WORDS(sex
,x0
,x1
,x
);
51 GET_LDOUBLE_WORDS(sep
,p0
,p1
,p
);
56 /* purge off exception values */
57 if((sep
|p0
|p1
)==0) return (x
*p
)/(x
*p
); /* p = 0 */
58 if((sex
==0x7fff)|| /* x not finite */
59 ((sep
==0x7fff)&& /* p is NaN */
64 if (sep
<0x7ffe) x
= __ieee754_fmodl(x
,p
+p
); /* now x < 2p */
65 if (((sex
-sep
)|(x0
-p0
)|(x1
-p1
))==0) return zero
*x
;
80 GET_LDOUBLE_EXP(sex
,x
);
81 SET_LDOUBLE_EXP(x
,sex
^sx
);