Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/third_party/fdlibm/fdlibm.cc

Issue 786823003: Implement Math.log2 via ported extract from fdlibm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm). 1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm).
2 // 2 //
3 // ==================================================== 3 // ====================================================
4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 // 5 //
6 // Developed at SunSoft, a Sun Microsystems, Inc. business. 6 // Developed at SunSoft, a Sun Microsystems, Inc. business.
7 // Permission to use, copy, modify, and distribute this 7 // Permission to use, copy, modify, and distribute this
8 // software is freely granted, provided that this notice 8 // software is freely granted, provided that this notice
9 // is preserved. 9 // is preserved.
10 // ==================================================== 10 // ====================================================
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 5.88041240820264096874e-04, // 26 56 5.88041240820264096874e-04, // 26
57 2.46463134818469906812e-04, // 27 57 2.46463134818469906812e-04, // 27
58 7.81794442939557092300e-05, // 28 58 7.81794442939557092300e-05, // 28
59 7.14072491382608190305e-05, // 29 59 7.14072491382608190305e-05, // 29
60 -1.85586374855275456654e-05, // 30 60 -1.85586374855275456654e-05, // 30
61 2.59073051863633712884e-05, // T12 31 61 2.59073051863633712884e-05, // T12 31
62 7.85398163397448278999e-01, // pio4 32 62 7.85398163397448278999e-01, // pio4 32
63 3.06161699786838301793e-17, // pio4lo 33 63 3.06161699786838301793e-17, // pio4lo 33
64 6.93147180369123816490e-01, // ln2_hi 34 64 6.93147180369123816490e-01, // ln2_hi 34
65 1.90821492927058770002e-10, // ln2_lo 35 65 1.90821492927058770002e-10, // ln2_lo 35
66 1.80143985094819840000e+16, // 2^54 36 66 6.666666666666666666e-01, // 2/3 36
67 6.666666666666666666e-01, // 2/3 37 67 6.666666666666735130e-01, // LP1 37 coefficients for log1p
68 6.666666666666735130e-01, // LP1 38 coefficients for log1p 68 3.999999999940941908e-01, // 38
69 3.999999999940941908e-01, // 39 69 2.857142874366239149e-01, // 39
70 2.857142874366239149e-01, // 40 70 2.222219843214978396e-01, // 40
71 2.222219843214978396e-01, // 41 71 1.818357216161805012e-01, // 41
72 1.818357216161805012e-01, // 42 72 1.531383769920937332e-01, // 42
73 1.531383769920937332e-01, // 43 73 1.479819860511658591e-01, // LP7 43
74 1.479819860511658591e-01, // LP7 44 74 7.09782712893383973096e+02, // 44 overflow threshold for expm1
75 7.09782712893383973096e+02, // 45 overflow threshold for expm1 75 1.44269504088896338700e+00, // 1/ln2 45
76 1.44269504088896338700e+00, // 1/ln2 46 76 -3.33333333333331316428e-02, // Q1 46 coefficients for expm1
77 -3.33333333333331316428e-02, // Q1 47 coefficients for expm1 77 1.58730158725481460165e-03, // 47
78 1.58730158725481460165e-03, // 48 78 -7.93650757867487942473e-05, // 48
79 -7.93650757867487942473e-05, // 49 79 4.00821782732936239552e-06, // 49
80 4.00821782732936239552e-06, // 50 80 -2.01099218183624371326e-07, // Q5 50
81 -2.01099218183624371326e-07, // Q5 51 81 710.4758600739439, // 51 overflow threshold sinh, cosh
82 710.4758600739439, // 52 overflow threshold sinh, cosh 82 4.34294481903251816668e-01, // ivln10 52 coefficients for log10
83 4.34294481903251816668e-01, // ivln10 53 coefficients for log10 83 3.01029995663611771306e-01, // log10_2hi 53
84 3.01029995663611771306e-01, // log10_2hi 54 84 3.69423907715893078616e-13, // log10_2lo 54
85 3.69423907715893078616e-13 // log10_2lo 55 85 5.99999999999994648725e-01, // L1 55 coefficients for log2
Raymond Toy 2014/12/10 17:15:53 Nit: Certainly would be nice to add (or move) a co
86 4.28571428578550184252e-01, // 56
87 3.33333329818377432918e-01, // 57
88 2.72728123808534006489e-01, // 58
89 2.30660745775561754067e-01, // 59
90 2.06975017800338417784e-01, // L6 60
91 9.61796693925975554329e-01, // cp 61 2/(3*ln(2))
92 9.61796700954437255859e-01, // cp_h 62
93 -7.02846165095275826516e-09, // cp_l 63
94 5.84962487220764160156e-01, // dp_h 64
95 1.35003920212974897128e-08 // dp_l 65
86 }; 96 };
87 97
88 98
89 // Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi 99 // Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
90 static const int two_over_pi[] = { 100 static const int two_over_pi[] = {
91 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 101 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C,
92 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, 102 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649,
93 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, 103 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44,
94 0x84E99C, 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 104 0x84E99C, 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B,
95 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 105 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 int n = __kernel_rem_pio2(tx, y, e0, nx); 285 int n = __kernel_rem_pio2(tx, y, e0, nx);
276 if (hx < 0) { 286 if (hx < 0) {
277 y[0] = -y[0]; 287 y[0] = -y[0];
278 y[1] = -y[1]; 288 y[1] = -y[1];
279 return -n; 289 return -n;
280 } 290 }
281 return n; 291 return n;
282 } 292 }
283 } 293 }
284 } // namespace v8::internal 294 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698