| 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 const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "IntegerImplementation can only be allocated by the VM"); | 10 "IntegerImplementation can only be allocated by the VM"); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 int pow(int exponent) { | 120 int pow(int exponent) { |
| 121 double res = this.toDouble().pow(exponent); | 121 double res = this.toDouble().pow(exponent); |
| 122 if (res.isInfinite()) { | 122 if (res.isInfinite()) { |
| 123 // Use Bigint instead. | 123 // Use Bigint instead. |
| 124 throw "IntegerImplementation.pow not implemented for large integers."; | 124 throw "IntegerImplementation.pow not implemented for large integers."; |
| 125 } | 125 } |
| 126 return res.toInt(); | 126 return res.toInt(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 String toStringAsFixed(int fractionDigits) { | 129 String toStringAsFixed(int fractionDigits) { |
| 130 // Issue 460. | 130 return this.toDouble().toStringAsFixed(fractionDigits); |
| 131 throw "IntegerImplementation.toStringAsFixed not implemented"; | |
| 132 } | 131 } |
| 133 String toStringAsExponential(int fractionDigits) { | 132 String toStringAsExponential(int fractionDigits) { |
| 134 // Issue 460. | 133 return this.toDouble().toStringAsExponential(fractionDigits); |
| 135 throw "IntegerImplementation.toStringAsExponential not implemented"; | |
| 136 } | 134 } |
| 137 String toStringAsPrecision(int precision) { | 135 String toStringAsPrecision(int precision) { |
| 138 // Issue 460. | 136 return this.toDouble().toStringAsPrecision(precision); |
| 139 throw "IntegerImplementation.toStringAsPrecision not implemented"; | |
| 140 } | 137 } |
| 141 String toRadixString(int radix) { | 138 String toRadixString(int radix) { |
| 142 final table = const ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | 139 final table = const ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", |
| 143 "A", "B", "C", "D", "E", "F"]; | 140 "A", "B", "C", "D", "E", "F"]; |
| 144 if ((radix <= 1) || (radix > 16)) { | 141 if ((radix <= 1) || (radix > 16)) { |
| 145 throw "Bad radix: $radix"; | 142 throw "Bad radix: $radix"; |
| 146 } | 143 } |
| 147 final bool isNegative = this < 0; | 144 final bool isNegative = this < 0; |
| 148 var value = isNegative ? -this : this; | 145 var value = isNegative ? -this : this; |
| 149 List temp = new List(); | 146 List temp = new List(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 219 } |
| 223 } | 220 } |
| 224 int shlFromInt(int other) { | 221 int shlFromInt(int other) { |
| 225 throw const OutOfMemoryException(); | 222 throw const OutOfMemoryException(); |
| 226 } | 223 } |
| 227 | 224 |
| 228 int pow(int exponent) { | 225 int pow(int exponent) { |
| 229 throw "Bigint.pow not implemented"; | 226 throw "Bigint.pow not implemented"; |
| 230 } | 227 } |
| 231 } | 228 } |
| OLD | NEW |