#ifndef lint static char sccsid[] = "@(#)fmod.c 1.1 92/07/30 SMI"; #endif /* * Copyright (c) 1988 by Sun Microsystems, Inc. */ #include static long is = 0x80000000, im = 0x000fffff, iu = 0x00100000; static double zero = 0.0, two110 = 1.29807421463370690713e+33, /* 46D00000 00000000 */ twom110 = 7.70371977754894341222e-34, /* 39100000 00000000 */ twom969 = 2.00416836000897277800e-292; /* 03600000 00000000 */ double fmod(x,y) double x,y ; { double a,b; long *px = (long*)&x; long *pa = (long*)&a; long *pb = (long*)&b; int n0,n1,n,k,ia,ib; int x0,y0,z0; unsigned x1,y1,z1; /* purge off exception values */ if(!finite(x)||y!=y||y==zero) return (x*y)/(x*y); a = fabs(x); b = fabs(y); if(a<=b) { if(a>20); x0 = iu|(im&pa[n0]); x1 = pa[n1]; y0 = iu|(im&pb[n0]); y1 = pb[n1]; /* fix point fmod */ /* while(n--) { z0=x0-y0;z1=x1-y1; if(x1>= 2; while(n--) { z0=x0-y0;z1=x1-y1; if(x1=0) {x0=z0;x1=z1;} /* convert back to floating value and restore the sign */ if((x0|x1)==0) {pa[n0]=px[n0]&is;pa[n1]=0;return a;} while((x0&iu)==0) { x0 = x0+x0+((x1&is)!=0); x1 = x1+x1; ib -= iu; } ib |= px[n0]&is; pa[n0] = ib|(x0&im); pa[n1] = x1; return a; }