e_log.c (170706) | e_log.c (170707) |
---|---|
1 2/* @(#)e_log.c 1.3 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 * Permission to use, copy, modify, and distribute this 9 * software is freely granted, provided that this notice 10 * is preserved. 11 * ==================================================== 12 */ 13 14#ifndef lint | 1 2/* @(#)e_log.c 1.3 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 * Permission to use, copy, modify, and distribute this 9 * software is freely granted, provided that this notice 10 * is preserved. 11 * ==================================================== 12 */ 13 14#ifndef lint |
15static char rcsid[] = "$FreeBSD: head/lib/msun/src/e_log.c 170706 2007-06-14 05:51:00Z bde $"; | 15static char rcsid[] = "$FreeBSD: head/lib/msun/src/e_log.c 170707 2007-06-14 05:57:13Z bde $"; |
16#endif 17 18/* __ieee754_log(x) 19 * Return the logrithm of x 20 * 21 * Method : 22 * 1. Argument Reduction: find k and f such that 23 * x = 2^k * (1+f), --- 78 unchanged lines hidden (view full) --- 102 } 103 if (hx >= 0x7ff00000) return x+x; 104 k += (hx>>20)-1023; 105 hx &= 0x000fffff; 106 i = (hx+0x95f64)&0x100000; 107 SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ 108 k += (i>>20); 109 f = x-1.0; | 16#endif 17 18/* __ieee754_log(x) 19 * Return the logrithm of x 20 * 21 * Method : 22 * 1. Argument Reduction: find k and f such that 23 * x = 2^k * (1+f), --- 78 unchanged lines hidden (view full) --- 102 } 103 if (hx >= 0x7ff00000) return x+x; 104 k += (hx>>20)-1023; 105 hx &= 0x000fffff; 106 i = (hx+0x95f64)&0x100000; 107 SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ 108 k += (i>>20); 109 f = x-1.0; |
110 if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ | 110 if((0x000fffff&(2+hx))<3) { /* -2**-20 <= f < 2**-20 */ |
111 if(f==zero) if(k==0) return zero; else {dk=(double)k; 112 return dk*ln2_hi+dk*ln2_lo;} 113 R = f*f*(0.5-0.33333333333333333*f); 114 if(k==0) return f-R; else {dk=(double)k; 115 return dk*ln2_hi-((R-dk*ln2_lo)-f);} 116 } 117 s = f/(2.0+f); 118 dk = (double)k; --- 17 unchanged lines hidden --- | 111 if(f==zero) if(k==0) return zero; else {dk=(double)k; 112 return dk*ln2_hi+dk*ln2_lo;} 113 R = f*f*(0.5-0.33333333333333333*f); 114 if(k==0) return f-R; else {dk=(double)k; 115 return dk*ln2_hi-((R-dk*ln2_lo)-f);} 116 } 117 s = f/(2.0+f); 118 dk = (double)k; --- 17 unchanged lines hidden --- |