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

Unified Diff: sdk/lib/core/duration.dart

Issue 17591020: Let operator* in Duration accept doubles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 7 years, 6 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/corelib/duration_big_num_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/duration.dart
diff --git a/sdk/lib/core/duration.dart b/sdk/lib/core/duration.dart
index a0cf1b601b64238d20732a84d79b2e1aa9d1f188..a19c6518969be539da409c5f3be837db04955f49 100644
--- a/sdk/lib/core/duration.dart
+++ b/sdk/lib/core/duration.dart
@@ -82,9 +82,12 @@ class Duration implements Comparable<Duration> {
/**
* Multiplies this [Duration] by the given [factor] and returns the result
* as a new [Duration].
+ *
+ * Note that when [factor] is a double, and the duration is greater than
+ * 53 bits, precision is lost because of double-precision arithmetic.
*/
- Duration operator *(int factor) {
- return new Duration(microseconds: _duration * factor);
+ Duration operator *(num factor) {
+ return new Duration(microseconds: (_duration * factor).round());
}
/**
« no previous file with comments | « no previous file | tests/corelib/duration_big_num_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698