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

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: reupload 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') | tests/corelib/duration_big_num_test.dart » ('J')
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..5d56e19b6977ad35b94c7fcc0e3dfd2fc3f1f859 100644
--- a/sdk/lib/core/duration.dart
+++ b/sdk/lib/core/duration.dart
@@ -56,7 +56,7 @@ class Duration implements Comparable<Duration> {
int minutes: 0,
int seconds: 0,
int milliseconds: 0,
- int microseconds: 0})
+ int microseconds: 0})
floitsch 2013/06/25 15:28:02 Remove trailing space.
zarah 2013/06/25 15:54:05 Done.
: _duration = days * MICROSECONDS_PER_DAY +
hours * MICROSECONDS_PER_HOUR +
minutes * MICROSECONDS_PER_MINUTE +
@@ -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 when [factor] is a double, and the duration is greater than
floitsch 2013/06/25 15:28:02 Note that ... or: Note: ...
zarah 2013/06/25 15:54:05 Done.
+ * 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') | tests/corelib/duration_big_num_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698