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

Unified Diff: runtime/lib/math_patch.dart

Issue 14619027: Fix for issue 10534. Implement int.pow correctly. Note that int.pow is considerably slower than dou… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/lib/integers.dart ('k') | tests/standalone/pow_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/math_patch.dart
===================================================================
--- runtime/lib/math_patch.dart (revision 22629)
+++ runtime/lib/math_patch.dart (working copy)
@@ -5,8 +5,11 @@
import "dart:typed_data";
// A VM patch of the dart:math library.
+
+// If [x] is an [int] and [exponent] is a non-negative [int], the result is
+// an [int], otherwise the result is a [double].
patch num pow(num x, num exponent) {
- if (exponent is int) {
+ if ((x is int) && (exponent is int) && (exponent >= 0)) {
return x.pow(exponent);
}
// Double.pow will call exponent.toDouble().
« no previous file with comments | « runtime/lib/integers.dart ('k') | tests/standalone/pow_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698