Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/Q/exp10l.c
+++ new/usr/src/lib/libm/common/Q/exp10l.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
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
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#pragma weak exp10l = __exp10l
31 -
32 30 #include "libm.h"
33 31 #include "longdouble.h"
34 32
35 33 /*
36 34 * exp10l(x)
37 35 * n = nint(x*(log10/log2)) ;
38 36 * exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2))
39 37 * = 2**n*exp(ln10*(x-n*log2/log10)))
40 38 * If x is an integer <= M then use repeat multiplication. For
41 39 * 10**M is the largest representable integer, where
42 40 * M = 10 single precision (24 bits)
43 41 * M = 22 double precision (53 bits)
44 42 * M = 48 quadruple precision (113 bits)
45 43 */
46 44
47 45 #define TINY 1.0e-20L /* single: 1e-5, double: 1e-10, quad: 1e-20 */
48 46 #define LG10OVT 4933.L /* single: 39, double: 309, quad: 4933 */
49 47 #define LG10UFT -4966.L /* single: -45, double: -323, quad: -4966 */
50 48 #define M 48
51 49 /* logt2hi : last 32 bits is zero for quad prec */
52 50 #define LOGT2HI 0.30102999566398119521373889472420986034688L
53 51 #define LOGT2LO 2.831664213089468167896664371953e-31L
54 52
55 53 static const long double
56 54 zero = 0.0L,
57 55 tiny = TINY * TINY,
58 56 one = 1.0L,
59 57 lg10 = 3.321928094887362347870319429489390175865e+0000L,
60 58 ln10 = 2.302585092994045684017991454684364207601e+0000L,
61 59 logt2hi = LOGT2HI,
62 60 logt2lo = LOGT2LO,
63 61 lg10ovt = LG10OVT,
64 62 lg10uft = LG10UFT;
65 63
66 64 long double
67 65 exp10l(long double x) {
68 66 long double t, tenp;
69 67 int k;
70 68
71 69 if (!finitel(x)) {
72 70 if (isnanl(x) || x > zero)
73 71 return (x + x);
74 72 else
75 73 return (zero);
76 74 }
77 75 if (fabsl(x) < tiny)
78 76 return (one + x);
79 77 if (x <= lg10ovt)
80 78 if (x >= lg10uft) {
81 79 k = (int) x;
82 80 tenp = 10.0L;
83 81 /* x is a small +integer */
84 82 if (0 <= k && k <= M && (long double) k == x) {
85 83 t = one;
86 84 if (k & 1)
87 85 t *= tenp;
88 86 k >>= 1;
89 87 while (k) {
90 88 tenp *= tenp;
91 89 if (k & 1)
92 90 t *= tenp;
93 91 k >>= 1;
94 92 }
95 93 return (t);
96 94 }
97 95 t = anintl(x * lg10);
98 96 return (scalbnl(expl(ln10 * ((x - t * logt2hi) -
99 97 t * logt2lo)), (int) t));
100 98 } else
101 99 return (scalbnl(one, -50000)); /* underflow */
102 100 else
103 101 return (scalbnl(one, 50000)); /* overflow */
104 102 }
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX