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

Unified Diff: runtime/lib/math_patch.dart

Issue 23073005: Make pow fail for non-number arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/math_patch.dart
diff --git a/runtime/lib/math_patch.dart b/runtime/lib/math_patch.dart
index f44e7b10f50879617bc9e1873b5e7b8d34dedba8..00cacdf22a27b82fb29b009e385d61332e48ba52 100644
--- a/runtime/lib/math_patch.dart
+++ b/runtime/lib/math_patch.dart
@@ -12,20 +12,18 @@ patch num pow(num x, num exponent) {
if ((x is int) && (exponent is int) && (exponent >= 0)) {
return _intPow(x, exponent);
}
- // doublePow will call exponent.toDouble().
- return _doublePow(x.toDouble(), exponent);
+ return _doublePow(x.toDouble(), exponent.toDouble());
}
-double _doublePow(double base, num exponent) {
- if (exponent == 0) {
+double _doublePow(double base, double exponent) {
+ if (exponent == 0.0) {
return 1.0; // ECMA-262 15.8.2.13
}
if (base == 1.0) return 1.0;
- double doubleExponent = exponent.toDouble();
if (base.isNaN || exponent.isNaN) {
return double.NAN;
}
- return _pow(base, doubleExponent);
+ return _pow(base, exponent);
}
double _pow(double base, double exponent) native "Math_doublePow";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698