Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -16,13 +16,15 @@
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
+
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -281,11 +283,12 @@
#define threshold1 C[10]
#define threshold2 C[11]
#define twom54 C[12]
double
-exp(double x) {
+exp(double x)
+{
double y, z, t;
int hx, ix, k, j, m;
ix = ((int *)&x)[HIWORD];
hx = ix & ~0x80000000;
@@ -297,61 +300,73 @@
dummy = (int)x; /* raise inexact if x != 0 */
#ifdef lint
dummy = dummy;
#endif
+
if (hx < 0x3e300000)
return (one + x);
+
return (one + x * (one + half * x));
}
+
t = x * x;
- y = x + (t * (half + x * t2) +
- (t * t) * (t3 + x * t4 + t * t5));
+ y = x + (t * (half + x * t2) + (t * t) * (t3 + x * t4 +
+ t * t5));
return (one + y);
}
/* find the multiple of 2^-6 nearest x */
k = hx >> 20;
j = (0x00100000 | (hx & 0x000fffff)) >> (0x40c - k);
j = (j - 1) & ~1;
+
if (ix < 0)
j += 134;
+
z = x - TBL2[j];
t = z * z;
- y = z + (t * (half + z * t2) +
- (t * t) * (t3 + z * t4 + t * t5));
- return (TBL2[j+1] + TBL2[j+1] * y);
+ y = z + (t * (half + z * t2) + (t * t) * (t3 + z * t4 + t *
+ t5));
+ return (TBL2[j + 1] + TBL2[j + 1] * y);
}
if (hx >= 0x40862e42) { /* x is large, infinite, or nan */
if (hx >= 0x7ff00000) {
if (ix == 0xfff00000 && ((int *)&x)[LOWORD] == 0)
return (zero);
+
return (x * x);
}
+
if (x > threshold1)
return (_SVID_libm_err(x, x, 6));
+
if (-x > threshold2)
return (_SVID_libm_err(x, x, 7));
}
t = invln2_32 * x;
+
if (ix < 0)
t -= half;
else
t += half;
+
k = (int)t;
j = (k & 0x1f) << 1;
m = k >> 5;
z = (x - k * ln2_32hi) - k * ln2_32lo;
/* z is now in primary range */
t = z * z;
y = z + (t * (half + z * t2) + (t * t) * (t3 + z * t4 + t * t5));
- y = TBL[j] + (TBL[j+1] + TBL[j] * y);
+ y = TBL[j] + (TBL[j + 1] + TBL[j] * y);
+
if (m < -1021) {
((int *)&y)[HIWORD] += (m + 54) << 20;
return (twom54 * y);
}
+
((int *)&y)[HIWORD] += m << 20;
return (y);
}