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 extends _Num implements double { | 5 class _Double extends _Num 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (lowerLimit.compareTo(upperLimit) > 0) { | 127 if (lowerLimit.compareTo(upperLimit) > 0) { |
128 throw new ArgumentError(lowerLimit); | 128 throw new ArgumentError(lowerLimit); |
129 } | 129 } |
130 if (lowerLimit.isNaN) return lowerLimit; | 130 if (lowerLimit.isNaN) return lowerLimit; |
131 if (this.compareTo(lowerLimit) < 0) return lowerLimit; | 131 if (this.compareTo(lowerLimit) < 0) return lowerLimit; |
132 if (this.compareTo(upperLimit) > 0) return upperLimit; | 132 if (this.compareTo(upperLimit) > 0) return upperLimit; |
133 return this; | 133 return this; |
134 } | 134 } |
135 | 135 |
136 int toInt() native "Double_toInt"; | 136 int toInt() native "Double_toInt"; |
| 137 _Bigint _toBigint() { return toInt()._toBigint(); } |
137 double toDouble() { return this; } | 138 double toDouble() { return this; } |
138 | 139 |
139 static const int CACHE_SIZE_LOG2 = 3; | 140 static const int CACHE_SIZE_LOG2 = 3; |
140 static const int CACHE_LENGTH = 1 << (CACHE_SIZE_LOG2 + 1); | 141 static const int CACHE_LENGTH = 1 << (CACHE_SIZE_LOG2 + 1); |
141 static const int CACHE_MASK = CACHE_LENGTH - 1; | 142 static const int CACHE_MASK = CACHE_LENGTH - 1; |
142 // Each key (double) followed by its toString result. | 143 // Each key (double) followed by its toString result. |
143 static final List _cache = new List(CACHE_LENGTH); | 144 static final List _cache = new List(CACHE_LENGTH); |
144 static int _cacheEvictIndex = 0; | 145 static int _cacheEvictIndex = 0; |
145 | 146 |
146 String toString() { | 147 String toString() { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return EQUAL; | 264 return EQUAL; |
264 } | 265 } |
265 } else if (isNaN) { | 266 } else if (isNaN) { |
266 return other.isNaN ? EQUAL : GREATER; | 267 return other.isNaN ? EQUAL : GREATER; |
267 } else { | 268 } else { |
268 // Other is NaN. | 269 // Other is NaN. |
269 return LESS; | 270 return LESS; |
270 } | 271 } |
271 } | 272 } |
272 } | 273 } |
OLD | NEW |