| Index: sdk/lib/math/math.dart
|
| ===================================================================
|
| --- sdk/lib/math/math.dart (revision 25101)
|
| +++ sdk/lib/math/math.dart (working copy)
|
| @@ -58,32 +58,24 @@
|
| * is returned.
|
| */
|
| num min(num a, num b) {
|
| - if (a is num) {
|
| - // TODO(floitsch): merge this if into the previous one, once dart2js
|
| - // correctly propagates types for logical ands.
|
| - if (b is num) {
|
| - if (a > b) return b;
|
| - if (a < b) return a;
|
| - if (b is double) {
|
| - // Special case for NaN and -0.0. If one argument is NaN return NaN.
|
| - // [min] must also distinguish between -0.0 and 0.0.
|
| - if (a is double) {
|
| - if (a == 0.0) {
|
| - // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN.
|
| - // The following returns -0.0 if either a or b is -0.0, and it
|
| - // returns NaN if b is NaN.
|
| - return (a + b) * a * b;
|
| - }
|
| - }
|
| - // Check for NaN and b == -0.0.
|
| - if (a == 0 && b.isNegative || b.isNaN) return b;
|
| - return a;
|
| + if (a > b) return b;
|
| + if (a < b) return a;
|
| + if (b is double) {
|
| + // Special case for NaN and -0.0. If one argument is NaN return NaN.
|
| + // [min] must also distinguish between -0.0 and 0.0.
|
| + if (a is double) {
|
| + if (a == 0.0) {
|
| + // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN.
|
| + // The following returns -0.0 if either a or b is -0.0, and it
|
| + // returns NaN if b is NaN.
|
| + return (a + b) * a * b;
|
| }
|
| - return a;
|
| }
|
| - throw new ArgumentError(b);
|
| + // Check for NaN and b == -0.0.
|
| + if (a == 0 && b.isNegative || b.isNaN) return b;
|
| + return a;
|
| }
|
| - throw new ArgumentError(a);
|
| + return a;
|
| }
|
|
|
| /**
|
| @@ -95,34 +87,26 @@
|
| * then it is unspecified which of the two arguments is returned.
|
| */
|
| num max(num a, num b) {
|
| - if (a is num) {
|
| - // TODO(floitsch): merge this if into the previous one, once dart2js
|
| - // correctly propagates types for logical ands.
|
| - if (b is num) {
|
| - if (a > b) return a;
|
| - if (a < b) return b;
|
| - if (b is double) {
|
| - // Special case for NaN and -0.0. If one argument is NaN return NaN.
|
| - // [max] must also distinguish between -0.0 and 0.0.
|
| - if (a is double) {
|
| - if (a == 0.0) {
|
| - // a is either 0.0 or -0.0. b is either 0.0, -0.0, or NaN.
|
| - // The following returns 0.0 if either a or b is 0.0, and it
|
| - // returns NaN if b is NaN.
|
| - return a + b;
|
| - }
|
| - }
|
| - // Check for NaN.
|
| - if (b.isNaN) return b;
|
| - return a;
|
| + if (a > b) return a;
|
| + if (a < b) return b;
|
| + if (b is double) {
|
| + // Special case for NaN and -0.0. If one argument is NaN return NaN.
|
| + // [max] must also distinguish between -0.0 and 0.0.
|
| + if (a is double) {
|
| + if (a == 0.0) {
|
| + // a is either 0.0 or -0.0. b is either 0.0, -0.0, or NaN.
|
| + // The following returns 0.0 if either a or b is 0.0, and it
|
| + // returns NaN if b is NaN.
|
| + return a + b;
|
| }
|
| - // max(-0.0, 0) must return 0.
|
| - if (b == 0 && a.isNegative) return b;
|
| - return a;
|
| }
|
| - throw new ArgumentError(b);
|
| + // Check for NaN.
|
| + if (b.isNaN) return b;
|
| + return a;
|
| }
|
| - throw new ArgumentError(a);
|
| + // max(-0.0, 0) must return 0.
|
| + if (b == 0 && a.isNegative) return b;
|
| + return a;
|
| }
|
|
|
| /**
|
|
|