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>
27 static const long double zero
= 0.0L;
31 __ieee754_remainderl(long double x
, long double p
)
36 double xhi
, xlo
, phi
, plo
;
38 ldbl_unpack (x
, &xhi
, &xlo
);
39 EXTRACT_WORDS64 (hx
, xhi
);
40 EXTRACT_WORDS64 (lx
, xlo
);
41 ldbl_unpack (p
, &phi
, &plo
);
42 EXTRACT_WORDS64 (hp
, phi
);
43 EXTRACT_WORDS64 (lp
, plo
);
44 sx
= hx
&0x8000000000000000ULL
;
45 hp
&= 0x7fffffffffffffffLL
;
46 hx
&= 0x7fffffffffffffffLL
;
48 /* purge off exception values */
49 if(hp
==0) return (x
*p
)/(x
*p
); /* p = 0 */
50 if((hx
>=0x7ff0000000000000LL
)|| /* x not finite */
51 (hp
>0x7ff0000000000000LL
)) /* p is NaN */
55 if (hp
<=0x7fdfffffffffffffLL
) x
= __ieee754_fmodl(x
,p
+p
); /* now x < 2p */
56 if (((hx
-hp
)|(lx
-lp
))==0) return zero
*x
;
59 if (hp
<0x0020000000000000LL
) {
75 strong_alias (__ieee754_remainderl
, __remainderl_finite
)