Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 var n = args[i] / max; | 147 var n = args[i] / max; |
| 148 var summand = n * n - compensation; | 148 var summand = n * n - compensation; |
| 149 var preliminary = sum + summand; | 149 var preliminary = sum + summand; |
| 150 compensation = (preliminary - sum) - summand; | 150 compensation = (preliminary - sum) - summand; |
| 151 sum = preliminary; | 151 sum = preliminary; |
| 152 } | 152 } |
| 153 return MathSqrt(sum) * max; | 153 return MathSqrt(sum) * max; |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 //ES6 draft 09-27-13, section 20.2.2.9. | |
| 158 function MathCbrt(x) { | |
| 159 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | |
| 160 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; | |
|
Jarin
2014/02/18 14:08:53
Is there any reason why you check for the corner c
| |
| 161 return %Math_cbrt(x); | |
| 162 } | |
| 163 | |
| 164 | |
| 165 //ES6 draft 09-27-13, section 20.2.2.14. | |
| 166 function MathExpm1(x) { | |
| 167 return %Math_expm1(TO_NUMBER_INLINE(x)); | |
| 168 } | |
| 169 | |
| 170 | |
| 171 //ES6 draft 09-27-13, section 20.2.2.20. | |
| 172 function MathLog1p(x) { | |
| 173 return %Math_log1p(TO_NUMBER_INLINE(x)); | |
| 174 } | |
| 175 | |
| 176 | |
| 157 function ExtendMath() { | 177 function ExtendMath() { |
| 158 %CheckIsBootstrapping(); | 178 %CheckIsBootstrapping(); |
| 159 | 179 |
| 160 // Set up the non-enumerable functions on the Math object. | 180 // Set up the non-enumerable functions on the Math object. |
| 161 InstallFunctions($Math, DONT_ENUM, $Array( | 181 InstallFunctions($Math, DONT_ENUM, $Array( |
| 162 "sign", MathSign, | 182 "sign", MathSign, |
| 163 "trunc", MathTrunc, | 183 "trunc", MathTrunc, |
| 164 "sinh", MathSinh, | 184 "sinh", MathSinh, |
| 165 "cosh", MathCosh, | 185 "cosh", MathCosh, |
| 166 "tanh", MathTanh, | 186 "tanh", MathTanh, |
| 167 "asinh", MathAsinh, | 187 "asinh", MathAsinh, |
| 168 "acosh", MathAcosh, | 188 "acosh", MathAcosh, |
| 169 "atanh", MathAtanh, | 189 "atanh", MathAtanh, |
| 170 "log10", MathLog10, | 190 "log10", MathLog10, |
| 171 "log2", MathLog2, | 191 "log2", MathLog2, |
| 172 "hypot", MathHypot | 192 "hypot", MathHypot, |
| 193 "cbrt", MathCbrt, | |
| 194 "log1p", MathLog1p, | |
| 195 "expm1", MathExpm1 | |
| 173 )); | 196 )); |
| 174 } | 197 } |
| 175 | 198 |
| 176 ExtendMath(); | 199 ExtendMath(); |
| OLD | NEW |