| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class Double implements double { | 5 class Double implements double { |
| 6 factory Double.fromInteger(int value) | 6 factory Double.fromInteger(int value) |
| 7 native "Double_doubleFromInteger"; | 7 native "Double_doubleFromInteger"; |
| 8 int hashCode() { | 8 int hashCode() { |
| 9 try { | 9 try { |
| 10 return toInt(); | 10 return toInt(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 double moduloFromInteger(int other) { | 84 double moduloFromInteger(int other) { |
| 85 return new Double.fromInteger(other) % this; | 85 return new Double.fromInteger(other) % this; |
| 86 } | 86 } |
| 87 double remainderFromInteger(int other) { | 87 double remainderFromInteger(int other) { |
| 88 return new Double.fromInteger(other).remainder(this); | 88 return new Double.fromInteger(other).remainder(this); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool greaterThanFromInteger(int other) native "Double_greaterThanFromInteger"; | 91 bool greaterThanFromInteger(int other) native "Double_greaterThanFromInteger"; |
| 92 | 92 |
| 93 bool isEven() { | |
| 94 // TODO(floitsch): find more efficient way to implement Double.isEven. | |
| 95 return this % 2.0 == 0.0; | |
| 96 } | |
| 97 bool isOdd() { | |
| 98 // TODO(floitsch): find more efficient way to implement Double.isOdd. | |
| 99 return this % 2.0 == 1.0; | |
| 100 } | |
| 101 bool isNegative() native "Double_isNegative"; | 93 bool isNegative() native "Double_isNegative"; |
| 102 bool isInfinite() native "Double_isInfinite"; | 94 bool isInfinite() native "Double_isInfinite"; |
| 103 bool isNaN() native "Double_isNaN"; | 95 bool isNaN() native "Double_isNaN"; |
| 104 | 96 |
| 105 double abs() { | 97 double abs() { |
| 106 // Handle negative 0.0. | 98 // Handle negative 0.0. |
| 107 if (this == 0.0) return 0.0; | 99 if (this == 0.0) return 0.0; |
| 108 return this < 0.0 ? -this : this; | 100 return this < 0.0 ? -this : this; |
| 109 } | 101 } |
| 110 | 102 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return EQUAL; | 206 return EQUAL; |
| 215 } | 207 } |
| 216 } else if (isNaN()) { | 208 } else if (isNaN()) { |
| 217 return other.isNaN() ? EQUAL : GREATER; | 209 return other.isNaN() ? EQUAL : GREATER; |
| 218 } else { | 210 } else { |
| 219 // Other is NaN. | 211 // Other is NaN. |
| 220 return LESS; | 212 return LESS; |
| 221 } | 213 } |
| 222 } | 214 } |
| 223 } | 215 } |
| OLD | NEW |