Index: src/math.js |
=================================================================== |
--- src/math.js (revision 2356) |
+++ src/math.js (working copy) |
@@ -68,10 +68,12 @@ |
} |
// ECMA 262 - 15.8.2.5 |
-function MathAtan2(x, y) { |
+// The naming of y and x matches the spec, as does the order in which |
+// ToNumber (valueOf) is called. |
+function MathAtan2(y, x) { |
+ if (!IS_NUMBER(y)) y = ToNumber(y); |
if (!IS_NUMBER(x)) x = ToNumber(x); |
- if (!IS_NUMBER(y)) y = ToNumber(y); |
- return %Math_atan2(x, y); |
+ return %Math_atan2(y, x); |
} |
// ECMA 262 - 15.8.2.6 |
@@ -117,11 +119,12 @@ |
// ECMA 262 - 15.8.2.11 |
function MathMax(arg1, arg2) { // length == 2 |
var r = -$Infinity; |
- for (var i = %_ArgumentsLength() - 1; i >= 0; --i) { |
+ var length = %_ArgumentsLength(); |
+ for (var i = 0; i < length; i++) { |
var n = ToNumber(%_Arguments(i)); |
if (NUMBER_IS_NAN(n)) return n; |
- // Make sure +0 is consider greater than -0. |
- if (n > r || (n === 0 && r === 0 && (1 / n) > (1 / r))) r = n; |
+ // Make sure +0 is considered greater than -0. |
+ if (n > r || (r === 0 && n === 0 && !%_IsSmi(r))) r = n; |
} |
return r; |
} |
@@ -129,11 +132,12 @@ |
// ECMA 262 - 15.8.2.12 |
function MathMin(arg1, arg2) { // length == 2 |
var r = $Infinity; |
- for (var i = %_ArgumentsLength() - 1; i >= 0; --i) { |
+ var length = %_ArgumentsLength(); |
+ for (var i = 0; i < length; i++) { |
var n = ToNumber(%_Arguments(i)); |
if (NUMBER_IS_NAN(n)) return n; |
- // Make sure -0 is consider less than +0. |
- if (n < r || (n === 0 && r === 0 && (1 / n) < (1 / r))) r = n; |
+ // Make sure -0 is considered less than +0. |
+ if (n < r || (r === 0 && n === 0 && !%_IsSmi(n))) r = n; |
} |
return r; |
} |