Print this page
11210 libm should be cstyle(1ONBLD) clean

*** 16,45 **** * 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. */ ! /* INDENT OFF */ /* * exp10(x) * Code by K.C. Ng for SUN 4.0 libm. * Method : * n = nint(x*(log10/log2)); * exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2)) * = 2**n*exp(ln10*(x-n*log2/log10))) * If x is an integer < 23 then use repeat multiplication. For * 10**22 is the largest representable integer. */ - /* INDENT ON */ #include "libm.h" static const double C[] = { 3.3219280948736234787, /* log(10)/log(2) */ --- 16,46 ---- * 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. */ ! /* * exp10(x) * Code by K.C. Ng for SUN 4.0 libm. * Method : * n = nint(x*(log10/log2)); * exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2)) * = 2**n*exp(ln10*(x-n*log2/log10))) * If x is an integer < 23 then use repeat multiplication. For * 10**22 is the largest representable integer. */ #include "libm.h" static const double C[] = { 3.3219280948736234787, /* log(10)/log(2) */
*** 64,108 **** #define ten C[7] #define huge C[8] #define tiny C[9] double ! exp10(double x) { double t, pt; int ix, hx, k; ix = ((int *)&x)[HIWORD]; hx = ix & ~0x80000000; if (hx >= 0x4074a000) { /* |x| >= 330 or x is nan */ if (hx >= 0x7ff00000) { /* x is inf or nan */ if (ix == 0xfff00000 && ((int *)&x)[LOWORD] == 0) return (zero); return (x * x); } ! t = (ix < 0)? tiny : huge; return (t * t); } if (hx < 0x3c000000) return (one + x); k = (int)x; if (0 <= k && k < 23 && (double)k == x) { /* x is a small positive integer */ t = one; pt = ten; if (k & 1) t = ten; k >>= 1; while (k) { pt *= pt; if (k & 1) t *= pt; k >>= 1; } return (t); } t = x * lg10; ! k = (int)((ix < 0)? t - half : t + half); return (scalbn(exp(ln10 * ((x - k * logt2hi) - k * logt2lo)), k)); } --- 65,120 ---- #define ten C[7] #define huge C[8] #define tiny C[9] double ! exp10(double x) ! { double t, pt; int ix, hx, k; ix = ((int *)&x)[HIWORD]; hx = ix & ~0x80000000; if (hx >= 0x4074a000) { /* |x| >= 330 or x is nan */ if (hx >= 0x7ff00000) { /* x is inf or nan */ if (ix == 0xfff00000 && ((int *)&x)[LOWORD] == 0) return (zero); + return (x * x); } ! ! t = (ix < 0) ? tiny : huge; return (t * t); } if (hx < 0x3c000000) return (one + x); k = (int)x; + if (0 <= k && k < 23 && (double)k == x) { /* x is a small positive integer */ t = one; pt = ten; + if (k & 1) t = ten; + k >>= 1; + while (k) { pt *= pt; + if (k & 1) t *= pt; + k >>= 1; } + return (t); } + t = x * lg10; ! k = (int)((ix < 0) ? t - half : t + half); return (scalbn(exp(ln10 * ((x - k * logt2hi) - k * logt2lo)), k)); }