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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/integers.dart
===================================================================
--- runtime/lib/integers.dart (revision 4405)
+++ runtime/lib/integers.dart (working copy)
@@ -118,7 +118,12 @@
double toDouble() { return new Double.fromInteger(this); }
int pow(int exponent) {
- throw "IntegerImplementation.pow not implemented";
+ double res = this.toDouble().pow(exponent);
siva 2012/02/22 01:10:43 our Bigint to double conversion is not implemented
srdjan 2012/02/22 01:38:59 Done.
+ if (res.isInfinite()) {
+ // Use Bigint instead.
+ throw "IntegerImplementation.pow not implemented for large integers.";
+ }
+ return res.toInt();
}
String toStringAsFixed(int fractionDigits) {
« 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