]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/ldbl-96/e_remainderl.c
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 /* __ieee754_remainderl(x,p)
19 * returns x REM p = x - [x/p]*p as if in infinite
20 * precise arithmetic, where [x/p] is the (infinite bit)
21 * integer nearest x/p (in half way case choose the even one).
23 * Based on fmod() return x-[x/p]chopped*p exactlp.
27 #include "math_private.h"
29 static const long double zero
= 0.0;
33 __ieee754_remainderl(long double x
, long double p
)
35 u_int32_t sx
,sex
,sep
,x0
,x1
,p0
,p1
;
38 GET_LDOUBLE_WORDS(sex
,x0
,x1
,x
);
39 GET_LDOUBLE_WORDS(sep
,p0
,p1
,p
);
44 /* purge off exception values */
45 if((sep
|p0
|p1
)==0) return (x
*p
)/(x
*p
); /* p = 0 */
46 if((sex
==0x7fff)|| /* x not finite */
47 ((sep
==0x7fff)&& /* p is NaN */
52 if (sep
<0x7ffe) x
= __ieee754_fmodl(x
,p
+p
); /* now x < 2p */
53 if (((sex
-sep
)|(x0
-p0
)|(x1
-p1
))==0) return zero
*x
;
68 GET_LDOUBLE_EXP(sex
,x
);
69 SET_LDOUBLE_EXP(x
,sex
^sx
);
72 strong_alias (__ieee754_remainderl
, __remainderl_finite
)