| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 8 |
| 9 Type get runtimeType => double; | 9 Type get runtimeType => double; |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (isNaN) return "NaN"; | 204 if (isNaN) return "NaN"; |
| 205 if (this == double.INFINITY) return "Infinity"; | 205 if (this == double.INFINITY) return "Infinity"; |
| 206 if (this == -double.INFINITY) return "-Infinity"; | 206 if (this == -double.INFINITY) return "-Infinity"; |
| 207 | 207 |
| 208 return _toStringAsPrecision(precision); | 208 return _toStringAsPrecision(precision); |
| 209 } | 209 } |
| 210 String _toStringAsPrecision(int fractionDigits) | 210 String _toStringAsPrecision(int fractionDigits) |
| 211 native "Double_toStringAsPrecision"; | 211 native "Double_toStringAsPrecision"; |
| 212 | 212 |
| 213 // Order is: NaN > Infinity > ... > 0.0 > -0.0 > ... > -Infinity. | 213 // Order is: NaN > Infinity > ... > 0.0 > -0.0 > ... > -Infinity. |
| 214 int compareTo(Comparable other) { | 214 int compareTo(num other) { |
| 215 final int EQUAL = 0, LESS = -1, GREATER = 1; | 215 final int EQUAL = 0, LESS = -1, GREATER = 1; |
| 216 if (this < other) { | 216 if (this < other) { |
| 217 return LESS; | 217 return LESS; |
| 218 } else if (this > other) { | 218 } else if (this > other) { |
| 219 return GREATER; | 219 return GREATER; |
| 220 } else if (this == other) { | 220 } else if (this == other) { |
| 221 if (this == 0.0) { | 221 if (this == 0.0) { |
| 222 bool thisIsNegative = isNegative; | 222 bool thisIsNegative = isNegative; |
| 223 bool otherIsNegative = other.isNegative; | 223 bool otherIsNegative = other.isNegative; |
| 224 if (thisIsNegative == otherIsNegative) { | 224 if (thisIsNegative == otherIsNegative) { |
| 225 return EQUAL; | 225 return EQUAL; |
| 226 } | 226 } |
| 227 return thisIsNegative ? LESS : GREATER; | 227 return thisIsNegative ? LESS : GREATER; |
| 228 } else { | 228 } else { |
| 229 return EQUAL; | 229 return EQUAL; |
| 230 } | 230 } |
| 231 } else if (isNaN) { | 231 } else if (isNaN) { |
| 232 return other.isNaN ? EQUAL : GREATER; | 232 return other.isNaN ? EQUAL : GREATER; |
| 233 } else { | 233 } else { |
| 234 // Other is NaN. | 234 // Other is NaN. |
| 235 return LESS; | 235 return LESS; |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| OLD | NEW |