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

Unified Diff: src/base/ieee754.cc

Issue 2079233005: [builtins] Make sure the Math functions and constants agree. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update the unittests. Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/ieee754.cc
diff --git a/src/base/ieee754.cc b/src/base/ieee754.cc
index 6da22ed8ec5485837c3d9ea1c5b117aa5aef9042..2b037ed21fef8722d970529f9598dd849301163b 100644
--- a/src/base/ieee754.cc
+++ b/src/base/ieee754.cc
@@ -1250,7 +1250,8 @@ double exp(double x) {
P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
- P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
+ P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
+ E = 2.718281828459045; /* 0x4005bf0a, 0x8b145769 */
static volatile double
huge = 1.0e+300,
@@ -1282,6 +1283,11 @@ double exp(double x) {
/* argument reduction */
if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
+ /* TODO(rtoy): We special case exp(1) here to return the correct
+ * value of E, as the computation below would get the last bit
+ * wrong. We should probably fix the algorithm instead.
+ */
+ if (x == 1.0) return E;
Raymond Toy 2016/06/21 16:20:12 It's probably not possible to fix the algorithm ea
Benedikt Meurer 2016/06/22 03:55:59 Since exp is not performance critical or anything,
Raymond Toy 2016/06/22 22:11:48 Yes, this is possible, and something that I would
Benedikt Meurer 2016/06/23 03:30:58 This would be super awesome and highly appreciated
hi = x - ln2HI[xsb];
lo = ln2LO[xsb];
k = 1 - xsb - xsb;
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698