fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / common / sf_modf.c
blob6c64e3fa02f6441b0824c40ff07fdb12643e6377
1 /* sf_modf.c -- float version of s_modf.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
16 #include "fdlibm.h"
18 #ifdef __STDC__
19 static const float one = 1.0;
20 #else
21 static float one = 1.0;
22 #endif
24 #ifdef __STDC__
25 float modff(float x, float *iptr)
26 #else
27 float modff(x, iptr)
28 float x,*iptr;
29 #endif
31 __int32_t i0,j0;
32 __uint32_t i;
33 GET_FLOAT_WORD(i0,x);
34 j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */
35 if(j0<23) { /* integer part in x */
36 if(j0<0) { /* |x|<1 */
37 SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */
38 return x;
39 } else {
40 i = (0x007fffff)>>j0;
41 if((i0&i)==0) { /* x is integral */
42 __uint32_t ix;
43 *iptr = x;
44 GET_FLOAT_WORD(ix,x);
45 SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
46 return x;
47 } else {
48 SET_FLOAT_WORD(*iptr,i0&(~i));
49 return x - *iptr;
52 } else { /* no fraction part */
53 __uint32_t ix;
54 *iptr = x*one;
55 GET_FLOAT_WORD(ix,x);
56 SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
57 return x;
61 #ifdef _DOUBLE_IS_32BITS
63 #ifdef __STDC__
64 double modf(double x, double *iptr)
65 #else
66 double modf(x, iptr)
67 double x,*iptr;
68 #endif
70 return (double) modff((float) x, (float *) iptr);
73 #endif /* defined(_DOUBLE_IS_32BITS) */