Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/C/exp10.c
+++ new/usr/src/lib/libm/common/C/exp10.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 +
21 22 /*
22 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 24 */
25 +
24 26 /*
25 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 28 * Use is subject to license terms.
27 29 */
28 30
29 -/* INDENT OFF */
31 +
30 32 /*
31 33 * exp10(x)
32 34 * Code by K.C. Ng for SUN 4.0 libm.
33 35 * Method :
34 36 * n = nint(x*(log10/log2));
35 37 * exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2))
36 38 * = 2**n*exp(ln10*(x-n*log2/log10)))
37 39 * If x is an integer < 23 then use repeat multiplication. For
38 40 * 10**22 is the largest representable integer.
39 41 */
40 -/* INDENT ON */
41 42
42 43 #include "libm.h"
43 44
44 45 static const double C[] = {
45 - 3.3219280948736234787, /* log(10)/log(2) */
46 - 2.3025850929940456840, /* log(10) */
46 + 3.3219280948736234787, /* log(10)/log(2) */
47 + 2.3025850929940456840, /* log(10) */
47 48 3.0102999565860955045E-1, /* log(2)/log(10) high */
48 49 5.3716447674669983622E-12, /* log(2)/log(10) low */
49 50 0.0,
50 51 0.5,
51 52 1.0,
52 53 10.0,
53 54 1.0e300,
54 55 1.0e-300,
55 56 };
56 57
57 -#define lg10 C[0]
58 -#define ln10 C[1]
59 -#define logt2hi C[2]
60 -#define logt2lo C[3]
61 -#define zero C[4]
62 -#define half C[5]
63 -#define one C[6]
64 -#define ten C[7]
65 -#define huge C[8]
66 -#define tiny C[9]
58 +#define lg10 C[0]
59 +#define ln10 C[1]
60 +#define logt2hi C[2]
61 +#define logt2lo C[3]
62 +#define zero C[4]
63 +#define half C[5]
64 +#define one C[6]
65 +#define ten C[7]
66 +#define huge C[8]
67 +#define tiny C[9]
67 68
68 69 double
69 -exp10(double x) {
70 - double t, pt;
71 - int ix, hx, k;
70 +exp10(double x)
71 +{
72 + double t, pt;
73 + int ix, hx, k;
72 74
73 75 ix = ((int *)&x)[HIWORD];
74 76 hx = ix & ~0x80000000;
75 77
76 - if (hx >= 0x4074a000) { /* |x| >= 330 or x is nan */
78 + if (hx >= 0x4074a000) { /* |x| >= 330 or x is nan */
77 79 if (hx >= 0x7ff00000) { /* x is inf or nan */
78 80 if (ix == 0xfff00000 && ((int *)&x)[LOWORD] == 0)
79 81 return (zero);
82 +
80 83 return (x * x);
81 84 }
82 - t = (ix < 0)? tiny : huge;
85 +
86 + t = (ix < 0) ? tiny : huge;
83 87 return (t * t);
84 88 }
85 89
86 90 if (hx < 0x3c000000)
87 91 return (one + x);
88 92
89 93 k = (int)x;
94 +
90 95 if (0 <= k && k < 23 && (double)k == x) {
91 96 /* x is a small positive integer */
92 97 t = one;
93 98 pt = ten;
99 +
94 100 if (k & 1)
95 101 t = ten;
102 +
96 103 k >>= 1;
104 +
97 105 while (k) {
98 106 pt *= pt;
107 +
99 108 if (k & 1)
100 109 t *= pt;
110 +
101 111 k >>= 1;
102 112 }
113 +
103 114 return (t);
104 115 }
116 +
105 117 t = x * lg10;
106 - k = (int)((ix < 0)? t - half : t + half);
118 + k = (int)((ix < 0) ? t - half : t + half);
107 119 return (scalbn(exp(ln10 * ((x - k * logt2hi) - k * logt2lo)), k));
108 120 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX