e_exp.c (176451) | e_exp.c (226596) |
---|---|
1 2/* @(#)e_exp.c 1.6 04/04/22 */ 3/* 4 * ==================================================== 5 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 */ 12 13#include <sys/cdefs.h> | 1 2/* @(#)e_exp.c 1.6 04/04/22 */ 3/* 4 * ==================================================== 5 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 */ 12 13#include <sys/cdefs.h> |
14__FBSDID("$FreeBSD: head/lib/msun/src/e_exp.c 176451 2008-02-22 02:30:36Z das $"); | 14__FBSDID("$FreeBSD: head/lib/msun/src/e_exp.c 226596 2011-10-21 06:26:38Z das $"); |
15 16/* __ieee754_exp(x) 17 * Returns the exponential of x. 18 * 19 * Method 20 * 1. Argument reduction: 21 * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. 22 * Given x, find r and integer k such that --- 48 unchanged lines hidden (view full) --- 71 * 72 * Constants: 73 * The hexadecimal values are the intended ones for the following 74 * constants. The decimal values may be used, provided that the 75 * compiler will convert from decimal to binary accurately enough 76 * to produce the hexadecimal values shown. 77 */ 78 | 15 16/* __ieee754_exp(x) 17 * Returns the exponential of x. 18 * 19 * Method 20 * 1. Argument reduction: 21 * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. 22 * Given x, find r and integer k such that --- 48 unchanged lines hidden (view full) --- 71 * 72 * Constants: 73 * The hexadecimal values are the intended ones for the following 74 * constants. The decimal values may be used, provided that the 75 * compiler will convert from decimal to binary accurately enough 76 * to produce the hexadecimal values shown. 77 */ 78 |
79#include <float.h> 80 |
|
79#include "math.h" 80#include "math_private.h" 81 82static const double 83one = 1.0, 84halF[2] = {0.5,-0.5,}, 85huge = 1.0e+300, 86o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ --- 41 unchanged lines hidden (view full) --- 128 if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ 129 hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; 130 } else { 131 k = (int)(invln2*x+halF[xsb]); 132 t = k; 133 hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ 134 lo = t*ln2LO[0]; 135 } | 81#include "math.h" 82#include "math_private.h" 83 84static const double 85one = 1.0, 86halF[2] = {0.5,-0.5,}, 87huge = 1.0e+300, 88o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ --- 41 unchanged lines hidden (view full) --- 130 if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ 131 hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; 132 } else { 133 k = (int)(invln2*x+halF[xsb]); 134 t = k; 135 hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ 136 lo = t*ln2LO[0]; 137 } |
136 x = hi - lo; | 138 STRICT_ASSIGN(double, x, hi - lo); |
137 } 138 else if(hx < 0x3e300000) { /* when |x|<2**-28 */ 139 if(huge+x>one) return one+x;/* trigger inexact */ 140 } 141 else k = 0; 142 143 /* x is now in primary range */ 144 t = x*x; --- 14 unchanged lines hidden --- | 139 } 140 else if(hx < 0x3e300000) { /* when |x|<2**-28 */ 141 if(huge+x>one) return one+x;/* trigger inexact */ 142 } 143 else k = 0; 144 145 /* x is now in primary range */ 146 t = x*x; --- 14 unchanged lines hidden --- |