e_fmod.c (117912) | e_fmod.c (141296) |
---|---|
1/* @(#)e_fmod.c 5.1 93/09/24 */ | 1 2/* @(#)e_fmod.c 1.3 95/01/18 */ |
2/* 3 * ==================================================== 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 * | 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * |
6 * Developed at SunPro, a Sun Microsystems, Inc. business. | 7 * Developed at SunSoft, a Sun Microsystems, Inc. business. |
7 * Permission to use, copy, modify, and distribute this | 8 * Permission to use, copy, modify, and distribute this |
8 * software is freely granted, provided that this notice | 9 * software is freely granted, provided that this notice |
9 * is preserved. 10 * ==================================================== 11 */ 12 13#ifndef lint | 10 * is preserved. 11 * ==================================================== 12 */ 13 14#ifndef lint |
14static char rcsid[] = "$FreeBSD: head/lib/msun/src/e_fmod.c 117912 2003-07-23 04:53:47Z peter $"; | 15static char rcsid[] = "$FreeBSD: head/lib/msun/src/e_fmod.c 141296 2005-02-04 18:26:06Z das $"; |
15#endif 16 | 16#endif 17 |
17/* | 18/* |
18 * __ieee754_fmod(x,y) 19 * Return x mod y in exact arithmetic 20 * Method: shift and subtract 21 */ 22 23#include "math.h" 24#include "math_private.h" 25 --- 12 unchanged lines hidden (view full) --- 38 hy &= 0x7fffffff; /* |y| */ 39 40 /* purge off exception values */ 41 if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */ 42 ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */ 43 return (x*y)/(x*y); 44 if(hx<=hy) { 45 if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */ | 19 * __ieee754_fmod(x,y) 20 * Return x mod y in exact arithmetic 21 * Method: shift and subtract 22 */ 23 24#include "math.h" 25#include "math_private.h" 26 --- 12 unchanged lines hidden (view full) --- 39 hy &= 0x7fffffff; /* |y| */ 40 41 /* purge off exception values */ 42 if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */ 43 ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */ 44 return (x*y)/(x*y); 45 if(hx<=hy) { 46 if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */ |
46 if(lx==ly) | 47 if(lx==ly) |
47 return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/ 48 } 49 50 /* determine ix = ilogb(x) */ 51 if(hx<0x00100000) { /* subnormal x */ 52 if(hx==0) { 53 for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; 54 } else { --- 6 unchanged lines hidden (view full) --- 61 if(hy==0) { 62 for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; 63 } else { 64 for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; 65 } 66 } else iy = (hy>>20)-1023; 67 68 /* set up {hx,lx}, {hy,ly} and align y to x */ | 48 return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/ 49 } 50 51 /* determine ix = ilogb(x) */ 52 if(hx<0x00100000) { /* subnormal x */ 53 if(hx==0) { 54 for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; 55 } else { --- 6 unchanged lines hidden (view full) --- 62 if(hy==0) { 63 for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; 64 } else { 65 for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; 66 } 67 } else iy = (hy>>20)-1023; 68 69 /* set up {hx,lx}, {hy,ly} and align y to x */ |
69 if(ix >= -1022) | 70 if(ix >= -1022) |
70 hx = 0x00100000|(0x000fffff&hx); 71 else { /* subnormal x, shift x to normal */ 72 n = -1022-ix; 73 if(n<=31) { 74 hx = (hx<<n)|(lx>>(32-n)); 75 lx <<= n; 76 } else { 77 hx = lx<<(n-32); 78 lx = 0; 79 } 80 } | 71 hx = 0x00100000|(0x000fffff&hx); 72 else { /* subnormal x, shift x to normal */ 73 n = -1022-ix; 74 if(n<=31) { 75 hx = (hx<<n)|(lx>>(32-n)); 76 lx <<= n; 77 } else { 78 hx = lx<<(n-32); 79 lx = 0; 80 } 81 } |
81 if(iy >= -1022) | 82 if(iy >= -1022) |
82 hy = 0x00100000|(0x000fffff&hy); 83 else { /* subnormal y, shift y to normal */ 84 n = -1022-iy; 85 if(n<=31) { 86 hy = (hy<<n)|(ly>>(32-n)); 87 ly <<= n; 88 } else { 89 hy = ly<<(n-32); --- 43 unchanged lines hidden --- | 83 hy = 0x00100000|(0x000fffff&hy); 84 else { /* subnormal y, shift y to normal */ 85 n = -1022-iy; 86 if(n<=31) { 87 hy = (hy<<n)|(ly>>(32-n)); 88 ly <<= n; 89 } else { 90 hy = ly<<(n-32); --- 43 unchanged lines hidden --- |