| 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 // TODO(srdjan): fix limitations. | 5 // TODO(srdjan): fix limitations. |
| 6 // - shift amount must be a Smi. | 6 // - shift amount must be a Smi. |
| 7 class _IntegerImplementation { | 7 class _IntegerImplementation { |
| 8 factory _IntegerImplementation._uninstantiable() { | 8 factory _IntegerImplementation._uninstantiable() { |
| 9 throw new UnsupportedError( | 9 throw new UnsupportedError( |
| 10 "_IntegerImplementation can only be allocated by the VM"); | 10 "_IntegerImplementation can only be allocated by the VM"); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 bool get isEven => ((this & 1) == 0); | 92 bool get isEven => ((this & 1) == 0); |
| 93 bool get isOdd => !isEven; | 93 bool get isOdd => !isEven; |
| 94 bool get isNaN => false; | 94 bool get isNaN => false; |
| 95 bool get isNegative => this < 0; | 95 bool get isNegative => this < 0; |
| 96 bool get isInfinite => false; | 96 bool get isInfinite => false; |
| 97 | 97 |
| 98 int compareTo(num other) { | 98 int compareTo(num other) { |
| 99 final int EQUAL = 0, LESS = -1, GREATER = 1; | 99 final int EQUAL = 0, LESS = -1, GREATER = 1; |
| 100 if (other is double) { | 100 if (other is double) { |
| 101 // TODO(floitsch): the following locals should be 'const'. | 101 // TODO(floitsch): the following locals should be 'const'. |
| 102 int MAX_EXACT_INT_TO_DOUBLE = 9007199254740991; // 2^53 - 1. | 102 int MAX_EXACT_INT_TO_DOUBLE = 9007199254740992; // 2^53. |
| 103 int MIN_EXACT_INT_TO_DOUBLE = -MAX_EXACT_INT_TO_DOUBLE; | 103 int MIN_EXACT_INT_TO_DOUBLE = -MAX_EXACT_INT_TO_DOUBLE; |
| 104 double d = other; | 104 double d = other; |
| 105 if (d.isInfinite) { | 105 if (d.isInfinite) { |
| 106 return d == double.NEGATIVE_INFINITY ? GREATER : LESS; | 106 return d == double.NEGATIVE_INFINITY ? GREATER : LESS; |
| 107 } | 107 } |
| 108 if (d.isNaN) { | 108 if (d.isNaN) { |
| 109 return LESS; | 109 return LESS; |
| 110 } | 110 } |
| 111 if (MIN_EXACT_INT_TO_DOUBLE <= this && this <= MAX_EXACT_INT_TO_DOUBLE) { | 111 if (MIN_EXACT_INT_TO_DOUBLE <= this && this <= MAX_EXACT_INT_TO_DOUBLE) { |
| 112 // Let the double implementation deal with -0.0. | 112 // Let the double implementation deal with -0.0. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } else { | 295 } else { |
| 296 return 0; | 296 return 0; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 int _shlFromInt(int other) native "Bigint_shlFromInt"; | 299 int _shlFromInt(int other) native "Bigint_shlFromInt"; |
| 300 | 300 |
| 301 int pow(int exponent) { | 301 int pow(int exponent) { |
| 302 throw "Bigint.pow not implemented"; | 302 throw "Bigint.pow not implemented"; |
| 303 } | 303 } |
| 304 } | 304 } |
| OLD | NEW |