Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: runtime/lib/integers.dart

Issue 10937011: Bug cleanup: unify on allowing radices from 2 to 36 in (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return this.toDouble().toStringAsFixed(fractionDigits); 147 return this.toDouble().toStringAsFixed(fractionDigits);
148 } 148 }
149 String toStringAsExponential(int fractionDigits) { 149 String toStringAsExponential(int fractionDigits) {
150 return this.toDouble().toStringAsExponential(fractionDigits); 150 return this.toDouble().toStringAsExponential(fractionDigits);
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"]; 157 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
158 if ((radix <= 1) || (radix > 16)) { 158 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
159 "u", "v", "w", "x", "y", "z"];
160 if ((radix <= 1) || (radix > 36)) {
159 throw "Bad radix: $radix"; 161 throw "Bad radix: $radix";
160 } 162 }
161 final bool isNegative = this < 0; 163 final bool isNegative = this < 0;
162 var value = isNegative ? -this : this; 164 var value = isNegative ? -this : this;
163 List temp = new List(); 165 List temp = new List();
164 while (value > 0) { 166 while (value > 0) {
165 var digit = value % radix; 167 var digit = value % radix;
166 value ~/= radix; 168 value ~/= radix;
167 temp.add(digit); 169 temp.add(digit);
168 } 170 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 238 }
237 } 239 }
238 int shlFromInt(int other) { 240 int shlFromInt(int other) {
239 throw const OutOfMemoryException(); 241 throw const OutOfMemoryException();
240 } 242 }
241 243
242 int pow(int exponent) { 244 int pow(int exponent) {
243 throw "Bigint.pow not implemented"; 245 throw "Bigint.pow not implemented";
244 } 246 }
245 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698