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

Side by Side Diff: src/harmony-math.js

Issue 119093006: Harmony: implement Math.log2 and Math.log10. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/harmony/math-log2-log10.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 function MathAtanh(x) { 103 function MathAtanh(x) {
104 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); 104 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
105 // Idempotent for +/-0. 105 // Idempotent for +/-0.
106 if (x === 0) return x; 106 if (x === 0) return x;
107 // Returns NaN for NaN and +/- Infinity. 107 // Returns NaN for NaN and +/- Infinity.
108 if (!NUMBER_IS_FINITE(x)) return NAN; 108 if (!NUMBER_IS_FINITE(x)) return NAN;
109 return 0.5 * MathLog((1 + x) / (1 - x)); 109 return 0.5 * MathLog((1 + x) / (1 - x));
110 } 110 }
111 111
112 112
113 //ES6 draft 09-27-13, section 20.2.2.21.
114 function MathLog10(x) {
115 return MathLog(x) * 0.434294481903251828; // log10(x) = log(x)/log(10).
116 }
117
118
119 //ES6 draft 09-27-13, section 20.2.2.22.
120 function MathLog2(x) {
121 return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2).
122 }
123
124
113 function ExtendMath() { 125 function ExtendMath() {
114 %CheckIsBootstrapping(); 126 %CheckIsBootstrapping();
115 127
116 // Set up the non-enumerable functions on the Math object. 128 // Set up the non-enumerable functions on the Math object.
117 InstallFunctions($Math, DONT_ENUM, $Array( 129 InstallFunctions($Math, DONT_ENUM, $Array(
118 "sign", MathSign, 130 "sign", MathSign,
119 "trunc", MathTrunc, 131 "trunc", MathTrunc,
120 "sinh", MathSinh, 132 "sinh", MathSinh,
121 "cosh", MathCosh, 133 "cosh", MathCosh,
122 "tanh", MathTanh, 134 "tanh", MathTanh,
123 "asinh", MathAsinh, 135 "asinh", MathAsinh,
124 "acosh", MathAcosh, 136 "acosh", MathAcosh,
125 "atanh", MathAtanh 137 "atanh", MathAtanh,
138 "log10", MathLog10,
139 "log2", MathLog2
126 )); 140 ));
127 } 141 }
128 142
129 ExtendMath(); 143 ExtendMath();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/math-log2-log10.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698