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 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid
[] = "$NetBSD: $";
22 * modfl(long double x, long double *iptr)
23 * return fraction part of x, and return x's integral part in *iptr.
32 #include "math_private.h"
35 static const long double one
= 1.0;
37 static long double one
= 1.0;
41 long double __modfl(long double x
, long double *iptr
)
43 long double __modfl(x
, iptr
)
49 GET_LDOUBLE_WORDS(se
,i0
,i1
,x
);
50 j0
= (se
&0x7fff)-0x3fff; /* exponent of x */
51 if(j0
<32) { /* integer part in high x */
52 if(j0
<0) { /* |x|<1 */
53 SET_LDOUBLE_WORDS(*iptr
,se
&0x8000,0,0); /* *iptr = +-0 */
57 if(((i0
&i
)|i1
)==0) { /* x is integral */
59 SET_LDOUBLE_WORDS(x
,se
&0x8000,0,0); /* return +-0 */
62 SET_LDOUBLE_WORDS(*iptr
,se
,i0
&(~i
),0);
66 } else if (j0
>63) { /* no fraction part */
68 /* We must handle NaNs separately. */
69 if (j0
== 0x4000 && ((i0
& 0x7fffffff) | i1
))
71 SET_LDOUBLE_WORDS(x
,se
&0x8000,0,0); /* return +-0 */
73 } else { /* fraction part in low x */
74 i
= ((u_int32_t
)(0xffffffff))>>(j0
-32);
75 if((i1
&i
)==0) { /* x is integral */
77 INSERT_WORDS(x
,se
&0x8000,0); /* return +-0 */
80 SET_LDOUBLE_WORDS(*iptr
,se
,i0
,i1
&(~i
));
85 weak_alias (__modfl
, modfl
)