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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 52 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
53 // Idempotent for NaN, +/-0 and +/-Infinity. | 53 // Idempotent for NaN, +/-0 and +/-Infinity. |
54 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; | 54 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; |
55 return (MathExp(x) - MathExp(-x)) / 2; | 55 return (MathExp(x) - MathExp(-x)) / 2; |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 // ES6 draft 09-27-13, section 20.2.2.12. | 59 // ES6 draft 09-27-13, section 20.2.2.12. |
60 function MathCosh(x) { | 60 function MathCosh(x) { |
61 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 61 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
62 // Idempotent for NaN and +/-Infinity. | 62 if (!NUMBER_IS_FINITE(x)) return MathAbs(x); |
63 if (!NUMBER_IS_FINITE(x)) return x; | |
64 return (MathExp(x) + MathExp(-x)) / 2; | 63 return (MathExp(x) + MathExp(-x)) / 2; |
65 } | 64 } |
66 | 65 |
67 | 66 |
68 // ES6 draft 09-27-13, section 20.2.2.33. | 67 // ES6 draft 09-27-13, section 20.2.2.33. |
69 function MathTanh(x) { | 68 function MathTanh(x) { |
70 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 69 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
71 // Idempotent for +/-0. | 70 // Idempotent for +/-0. |
72 if (x === 0) return x; | 71 if (x === 0) return x; |
73 // Returns +/-1 for +/-Infinity. | 72 // Returns +/-1 for +/-Infinity. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 "asinh", MathAsinh, | 167 "asinh", MathAsinh, |
169 "acosh", MathAcosh, | 168 "acosh", MathAcosh, |
170 "atanh", MathAtanh, | 169 "atanh", MathAtanh, |
171 "log10", MathLog10, | 170 "log10", MathLog10, |
172 "log2", MathLog2, | 171 "log2", MathLog2, |
173 "hypot", MathHypot | 172 "hypot", MathHypot |
174 )); | 173 )); |
175 } | 174 } |
176 | 175 |
177 ExtendMath(); | 176 ExtendMath(); |
OLD | NEW |