| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool get isInfinite native "Double_getIsInfinite"; | 97 bool get isInfinite native "Double_getIsInfinite"; |
| 98 bool get isNaN native "Double_getIsNaN"; | 98 bool get isNaN native "Double_getIsNaN"; |
| 99 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. | 99 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. |
| 100 | 100 |
| 101 double abs() { | 101 double abs() { |
| 102 // Handle negative 0.0. | 102 // Handle negative 0.0. |
| 103 if (this == 0.0) return 0.0; | 103 if (this == 0.0) return 0.0; |
| 104 return this < 0.0 ? -this : this; | 104 return this < 0.0 ? -this : this; |
| 105 } | 105 } |
| 106 | 106 |
| 107 double get sign { |
| 108 if (this > 0.0) return 1.0; |
| 109 if (this < 0.0) return -1.0; |
| 110 return this; // +/-0.0 or NaN. |
| 111 } |
| 112 |
| 107 int round() => roundToDouble().toInt(); | 113 int round() => roundToDouble().toInt(); |
| 108 int floor() => floorToDouble().toInt(); | 114 int floor() => floorToDouble().toInt(); |
| 109 int ceil () => ceilToDouble().toInt(); | 115 int ceil () => ceilToDouble().toInt(); |
| 110 int truncate() => truncateToDouble().toInt(); | 116 int truncate() => truncateToDouble().toInt(); |
| 111 | 117 |
| 112 double roundToDouble() native "Double_round"; | 118 double roundToDouble() native "Double_round"; |
| 113 double floorToDouble() native "Double_floor"; | 119 double floorToDouble() native "Double_floor"; |
| 114 double ceilToDouble() native "Double_ceil"; | 120 double ceilToDouble() native "Double_ceil"; |
| 115 double truncateToDouble() native "Double_truncate"; | 121 double truncateToDouble() native "Double_truncate"; |
| 116 | 122 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return EQUAL; | 236 return EQUAL; |
| 231 } | 237 } |
| 232 } else if (isNaN) { | 238 } else if (isNaN) { |
| 233 return other.isNaN ? EQUAL : GREATER; | 239 return other.isNaN ? EQUAL : GREATER; |
| 234 } else { | 240 } else { |
| 235 // Other is NaN. | 241 // Other is NaN. |
| 236 return LESS; | 242 return LESS; |
| 237 } | 243 } |
| 238 } | 244 } |
| 239 } | 245 } |
| OLD | NEW |