1 /* s_modfl.c -- long double version of s_modf.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 * ====================================================
18 * modfl(long double x, long double *iptr)
19 * return fraction part of x, and return x's integral part in *iptr.
28 #include <math_private.h>
30 static const long double one
= 1.0;
33 __modfl(long double x
, long double *iptr
)
37 GET_LDOUBLE_WORDS(se
,i0
,i1
,x
);
38 j0
= (se
&0x7fff)-0x3fff; /* exponent of x */
39 if(j0
<32) { /* integer part in high x */
40 if(j0
<0) { /* |x|<1 */
41 SET_LDOUBLE_WORDS(*iptr
,se
&0x8000,0,0); /* *iptr = +-0 */
45 if(((i0
&i
)|i1
)==0) { /* x is integral */
47 SET_LDOUBLE_WORDS(x
,se
&0x8000,0,0); /* return +-0 */
50 SET_LDOUBLE_WORDS(*iptr
,se
,i0
&(~i
),0);
54 } else if (__builtin_expect(j0
>63, 0)) { /* no fraction part */
56 /* We must handle NaNs separately. */
57 if (j0
== 0x4000 && ((i0
& 0x7fffffff) | i1
))
59 SET_LDOUBLE_WORDS(x
,se
&0x8000,0,0); /* return +-0 */
61 } else { /* fraction part in low x */
62 i
= ((u_int32_t
)(0x7fffffff))>>(j0
-32);
63 if((i1
&i
)==0) { /* x is integral */
65 SET_LDOUBLE_WORDS(x
,se
&0x8000,0,0); /* return +-0 */
68 SET_LDOUBLE_WORDS(*iptr
,se
,i0
,i1
&(~i
));
73 weak_alias (__modfl
, modfl
)