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

Unified Diff: src/math.js

Issue 465353002: Implement Math.expm1 using port from fdlibm. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | test/mjsunit/es6/math-expm1.js » ('j') | test/mjsunit/es6/math-expm1.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index 13cdb31cdcf5ec0b58a24d4ad9daf1f10b5561bf..00a507a28e5514d0ebdfcb81acc194821e443a98 100644
--- a/src/math.js
+++ b/src/math.js
@@ -327,26 +327,6 @@ function CubeRoot(x) {
return NEWTON_ITERATION_CBRT(x, approx);
}
-// ES6 draft 09-27-13, section 20.2.2.14.
-// Use Taylor series to approximate.
-// exp(x) - 1 at 0 == -1 + exp(0) + exp'(0)*x/1! + exp''(0)*x^2/2! + ...
-// == x/1! + x^2/2! + x^3/3! + ...
-// The closer x is to 0, the fewer terms are required.
-function MathExpm1(x) {
- if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
- var xabs = MathAbs(x);
- if (xabs < 2E-7) {
- return x * (1 + x * (1/2));
- } else if (xabs < 6E-5) {
- return x * (1 + x * (1/2 + x * (1/6)));
- } else if (xabs < 2E-2) {
- return x * (1 + x * (1/2 + x * (1/6 +
- x * (1/24 + x * (1/120 + x * (1/720))))));
- } else { // Use regular exp if not close enough to 0.
- return MathExp(x) - 1;
- }
-}
-
// -------------------------------------------------------------------
function SetUpMath() {
@@ -408,8 +388,8 @@ function SetUpMath() {
"fround", MathFroundJS,
"clz32", MathClz32,
"cbrt", MathCbrt,
- "log1p", MathLog1p, // implemented by third_party/fdlibm
- "expm1", MathExpm1
+ "log1p", MathLog1p, // implemented by third_party/fdlibm
+ "expm1", MathExpm1 // implemented by third_party/fdlibm
));
%SetInlineBuiltinFlag(MathCeil);
« no previous file with comments | « no previous file | test/mjsunit/es6/math-expm1.js » ('j') | test/mjsunit/es6/math-expm1.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698