]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/ldbl-128ibm/e_remainderl.c
1 /* e_fmodl.c -- long double version of e_fmod.c.
2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
15 /* __ieee754_remainderl(x,p)
17 * returns x REM p = x - [x/p]*p as if in infinite
18 * precise arithmetic, where [x/p] is the (infinite bit)
19 * integer nearest x/p (in half way case choose the even one).
21 * Based on fmodl() return x-[x/p]chopped*p exactlp.
25 #include "math_private.h"
28 static const long double zero
= 0.0L;
30 static long double zero
= 0.0L;
35 long double __ieee754_remainderl(long double x
, long double p
)
37 long double __ieee754_remainderl(x
,p
)
45 GET_LDOUBLE_WORDS64(hx
,lx
,x
);
46 GET_LDOUBLE_WORDS64(hp
,lp
,p
);
47 sx
= hx
&0x8000000000000000ULL
;
48 hp
&= 0x7fffffffffffffffLL
;
49 hx
&= 0x7fffffffffffffffLL
;
51 /* purge off exception values */
52 if((hp
|(lp
&0x7fffffffffffffff))==0) return (x
*p
)/(x
*p
); /* p = 0 */
53 if((hx
>=0x7ff0000000000000LL
)|| /* x not finite */
54 ((hp
>=0x7ff0000000000000LL
)&& /* p is NaN */
55 (((hp
-0x7ff0000000000000LL
)|lp
)!=0)))
59 if (hp
<=0x7fdfffffffffffffLL
) x
= __ieee754_fmodl(x
,p
+p
); /* now x < 2p */
60 if (((hx
-hp
)|(lx
-lp
))==0) return zero
*x
;
63 if (hp
<0x0020000000000000LL
) {
75 GET_LDOUBLE_MSW64(hx
,x
);
76 SET_LDOUBLE_MSW64(x
,hx
^sx
);