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

Side by Side Diff: src/math.js

Issue 739913003: Implement log10 via fdlibm port. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 6 years, 1 month 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
« no previous file with comments | « no previous file | src/third_party/fdlibm/fdlibm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declarations have been made 7 // This file relies on the fact that the following declarations have been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Object = global.Object; 9 // var $Object = global.Object;
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // ES6 draft 09-27-13, section 20.2.2.7. 220 // ES6 draft 09-27-13, section 20.2.2.7.
221 function MathAtanh(x) { 221 function MathAtanh(x) {
222 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); 222 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
223 // Idempotent for +/-0. 223 // Idempotent for +/-0.
224 if (x === 0) return x; 224 if (x === 0) return x;
225 // Returns NaN for NaN and +/- Infinity. 225 // Returns NaN for NaN and +/- Infinity.
226 if (!NUMBER_IS_FINITE(x)) return NAN; 226 if (!NUMBER_IS_FINITE(x)) return NAN;
227 return 0.5 * MathLog((1 + x) / (1 - x)); 227 return 0.5 * MathLog((1 + x) / (1 - x));
228 } 228 }
229 229
230 // ES6 draft 09-27-13, section 20.2.2.21.
231 function MathLog10(x) {
232 return MathLog(x) * 0.434294481903251828; // log10(x) = log(x)/log(10).
233 }
234
235
236 // ES6 draft 09-27-13, section 20.2.2.22. 230 // ES6 draft 09-27-13, section 20.2.2.22.
237 function MathLog2(x) { 231 function MathLog2(x) {
238 return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2). 232 return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2).
239 } 233 }
240 234
241 // ES6 draft 09-27-13, section 20.2.2.17. 235 // ES6 draft 09-27-13, section 20.2.2.17.
242 function MathHypot(x, y) { // Function length is 2. 236 function MathHypot(x, y) { // Function length is 2.
243 // We may want to introduce fast paths for two arguments and when 237 // We may want to introduce fast paths for two arguments and when
244 // normalization to avoid overflow is not necessary. For now, we 238 // normalization to avoid overflow is not necessary. For now, we
245 // simply assume the general case. 239 // simply assume the general case.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 "min", MathMin, 356 "min", MathMin,
363 "imul", MathImul, 357 "imul", MathImul,
364 "sign", MathSign, 358 "sign", MathSign,
365 "trunc", MathTrunc, 359 "trunc", MathTrunc,
366 "sinh", MathSinh, // implemented by third_party/fdlibm 360 "sinh", MathSinh, // implemented by third_party/fdlibm
367 "cosh", MathCosh, // implemented by third_party/fdlibm 361 "cosh", MathCosh, // implemented by third_party/fdlibm
368 "tanh", MathTanh, 362 "tanh", MathTanh,
369 "asinh", MathAsinh, 363 "asinh", MathAsinh,
370 "acosh", MathAcosh, 364 "acosh", MathAcosh,
371 "atanh", MathAtanh, 365 "atanh", MathAtanh,
372 "log10", MathLog10, 366 "log10", MathLog10, // implemented by third_party/fdlibm
373 "log2", MathLog2, 367 "log2", MathLog2,
374 "hypot", MathHypot, 368 "hypot", MathHypot,
375 "fround", MathFroundJS, 369 "fround", MathFroundJS,
376 "clz32", MathClz32, 370 "clz32", MathClz32,
377 "cbrt", MathCbrt, 371 "cbrt", MathCbrt,
378 "log1p", MathLog1p, // implemented by third_party/fdlibm 372 "log1p", MathLog1p, // implemented by third_party/fdlibm
379 "expm1", MathExpm1 // implemented by third_party/fdlibm 373 "expm1", MathExpm1 // implemented by third_party/fdlibm
380 )); 374 ));
381 375
382 %SetInlineBuiltinFlag(MathCeil); 376 %SetInlineBuiltinFlag(MathCeil);
383 %SetInlineBuiltinFlag(MathRandom); 377 %SetInlineBuiltinFlag(MathRandom);
384 %SetInlineBuiltinFlag(MathSin); 378 %SetInlineBuiltinFlag(MathSin);
385 %SetInlineBuiltinFlag(MathCos); 379 %SetInlineBuiltinFlag(MathCos);
386 } 380 }
387 381
388 SetUpMath(); 382 SetUpMath();
OLDNEW
« no previous file with comments | « no previous file | src/third_party/fdlibm/fdlibm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698