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

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

Issue 9372078: Fix for 1267: Implement (partially) Math.pow for integers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 int round() { return this; } 112 int round() { return this; }
113 int floor() { return this; } 113 int floor() { return this; }
114 int ceil() { return this; } 114 int ceil() { return this; }
115 int truncate() { return this; } 115 int truncate() { return this; }
116 116
117 int toInt() { return this; } 117 int toInt() { return this; }
118 double toDouble() { return new Double.fromInteger(this); } 118 double toDouble() { return new Double.fromInteger(this); }
119 119
120 int pow(int exponent) { 120 int pow(int exponent) {
121 throw "IntegerImplementation.pow not implemented"; 121 double res = this.toDouble().pow(exponent);
122 if (res.isInfinite()) {
123 // Use Bigint instead.
124 throw "IntegerImplementation.pow not implemented for large integers.";
125 }
126 return res.toInt();
122 } 127 }
123 128
124 String toStringAsFixed(int fractionDigits) { 129 String toStringAsFixed(int fractionDigits) {
125 // Issue 460. 130 // Issue 460.
126 throw "IntegerImplementation.toStringAsFixed not implemented"; 131 throw "IntegerImplementation.toStringAsFixed not implemented";
127 } 132 }
128 String toStringAsExponential(int fractionDigits) { 133 String toStringAsExponential(int fractionDigits) {
129 // Issue 460. 134 // Issue 460.
130 throw "IntegerImplementation.toStringAsExponential not implemented"; 135 throw "IntegerImplementation.toStringAsExponential not implemented";
131 } 136 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 int shrFromInt(int other) { 217 int shrFromInt(int other) {
213 if (other < 0) { 218 if (other < 0) {
214 return -1; 219 return -1;
215 } else { 220 } else {
216 return 0; 221 return 0;
217 } 222 }
218 } 223 }
219 int shlFromInt(int other) { 224 int shlFromInt(int other) {
220 throw const OutOfMemoryException(); 225 throw const OutOfMemoryException();
221 } 226 }
227
228 int pow(int exponent) {
229 throw "Bigint.pow not implemented";
230 }
222 } 231 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698