00001 #if !defined(__ppc__)
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #if defined(LIBM_SCCS) && !defined(lint)
00015 static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $";
00016 #endif
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "math.h"
00029 #include "mathP.h"
00030
00031 #ifdef __STDC__
00032 static const double one = 1.0;
00033 #else
00034 static double one = 1.0;
00035 #endif
00036
00037 #ifdef __STDC__
00038 double modf(double x, double *iptr)
00039 #else
00040 double modf(x, iptr)
00041 double x,*iptr;
00042 #endif
00043 {
00044 int32_t i0,i1,j0;
00045 u_int32_t i;
00046 EXTRACT_WORDS(i0,i1,x);
00047 j0 = ((i0>>20)&0x7ff)-0x3ff;
00048 if(j0<20) {
00049 if(j0<0) {
00050 INSERT_WORDS(*iptr,i0&0x80000000,0);
00051 return x;
00052 } else {
00053 i = (0x000fffff)>>j0;
00054 if(((i0&i)|i1)==0) {
00055 u_int32_t high;
00056 *iptr = x;
00057 GET_HIGH_WORD(high,x);
00058 INSERT_WORDS(x,high&0x80000000,0);
00059 return x;
00060 } else {
00061 INSERT_WORDS(*iptr,i0&(~i),0);
00062 return x - *iptr;
00063 }
00064 }
00065 } else if (j0>51) {
00066 u_int32_t high;
00067 *iptr = x*one;
00068 GET_HIGH_WORD(high,x);
00069 INSERT_WORDS(x,high&0x80000000,0);
00070 return x;
00071 } else {
00072 i = ((u_int32_t)(0xffffffff))>>(j0-20);
00073 if((i1&i)==0) {
00074 u_int32_t high;
00075 *iptr = x;
00076 GET_HIGH_WORD(high,x);
00077 INSERT_WORDS(x,high&0x80000000,0);
00078 return x;
00079 } else {
00080 INSERT_WORDS(*iptr,i0,i1&(~i));
00081 return x - *iptr;
00082 }
00083 }
00084 }
00085 #endif