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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 String toStringAsPrecision(int precision) { | 152 String toStringAsPrecision(int precision) { |
153 return this.toDouble().toStringAsPrecision(precision); | 153 return this.toDouble().toStringAsPrecision(precision); |
154 } | 154 } |
155 String toRadixString(int radix) { | 155 String toRadixString(int radix) { |
156 final table = const ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | 156 final table = const ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", |
157 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", | 157 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", |
158 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", | 158 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", |
159 "u", "v", "w", "x", "y", "z"]; | 159 "u", "v", "w", "x", "y", "z"]; |
160 if (radix < 2 || radix > 36) { | 160 if (radix < 2 || radix > 36) { |
161 throw new IllegalArgumentException(radix); | 161 throw new ArgumentError(radix); |
162 } | 162 } |
163 final bool isNegative = this < 0; | 163 final bool isNegative = this < 0; |
164 var value = isNegative ? -this : this; | 164 var value = isNegative ? -this : this; |
165 List temp = new List(); | 165 List temp = new List(); |
166 while (value > 0) { | 166 while (value > 0) { |
167 var digit = value % radix; | 167 var digit = value % radix; |
168 value ~/= radix; | 168 value ~/= radix; |
169 temp.add(digit); | 169 temp.add(digit); |
170 } | 170 } |
171 if (temp.isEmpty()) { | 171 if (temp.isEmpty()) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 } | 239 } |
240 int shlFromInt(int other) { | 240 int shlFromInt(int other) { |
241 throw const OutOfMemoryException(); | 241 throw const OutOfMemoryException(); |
242 } | 242 } |
243 | 243 |
244 int pow(int exponent) { | 244 int pow(int exponent) { |
245 throw "Bigint.pow not implemented"; | 245 throw "Bigint.pow not implemented"; |
246 } | 246 } |
247 } | 247 } |
OLD | NEW |