| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return this.toDouble().toStringAsFixed(fractionDigits); | 130 return this.toDouble().toStringAsFixed(fractionDigits); |
| 131 } | 131 } |
| 132 String toStringAsExponential(int fractionDigits) { | 132 String toStringAsExponential(int fractionDigits) { |
| 133 return this.toDouble().toStringAsExponential(fractionDigits); | 133 return this.toDouble().toStringAsExponential(fractionDigits); |
| 134 } | 134 } |
| 135 String toStringAsPrecision(int precision) { | 135 String toStringAsPrecision(int precision) { |
| 136 return this.toDouble().toStringAsPrecision(precision); | 136 return this.toDouble().toStringAsPrecision(precision); |
| 137 } | 137 } |
| 138 String toRadixString(int radix) { | 138 String toRadixString(int radix) { |
| 139 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", |
| 140 "A", "B", "C", "D", "E", "F"]; | 140 "a", "b", "c", "d", "e", "f"]; |
| 141 if ((radix <= 1) || (radix > 16)) { | 141 if ((radix <= 1) || (radix > 16)) { |
| 142 throw "Bad radix: $radix"; | 142 throw "Bad radix: $radix"; |
| 143 } | 143 } |
| 144 final bool isNegative = this < 0; | 144 final bool isNegative = this < 0; |
| 145 var value = isNegative ? -this : this; | 145 var value = isNegative ? -this : this; |
| 146 List temp = new List(); | 146 List temp = new List(); |
| 147 while (value > 0) { | 147 while (value > 0) { |
| 148 var digit = value % radix; | 148 var digit = value % radix; |
| 149 value ~/= radix; | 149 value ~/= radix; |
| 150 temp.add(digit); | 150 temp.add(digit); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 int shlFromInt(int other) { | 221 int shlFromInt(int other) { |
| 222 throw const OutOfMemoryException(); | 222 throw const OutOfMemoryException(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 int pow(int exponent) { | 225 int pow(int exponent) { |
| 226 throw "Bigint.pow not implemented"; | 226 throw "Bigint.pow not implemented"; |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |