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

Unified Diff: runtime/lib/double.dart

Issue 9565035: Some fixes to Math.pow. (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/double.dart
===================================================================
--- runtime/lib/double.dart (revision 4834)
+++ runtime/lib/double.dart (working copy)
@@ -112,7 +112,15 @@
double toDouble() { return this; }
double pow(num exponent) {
- return _pow(exponent.toDouble());
+ if (exponent == 0) {
+ return 1.0; // ECMA-262 15.8.2.13
ngeoffray 2012/03/02 07:55:47 Wouldn't it be better to point to Dart spec instea
srdjan 2012/03/02 17:55:37 Good point. There is no Dart library spec for "pow
+ }
+ // Throw NullPointerException if exponent is null.
+ double doubleExponent = exponent.toDouble();
+ if (isNaN() || exponent.isNaN()) {
+ return double.NAN;
+ }
+ return _pow(doubleExponent);
}
double _pow(double exponent) native "Double_pow";
« 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