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

Unified Diff: runtime/lib/double.dart

Issue 12317107: ceil/floor/truncate/round return integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Some fixes from CL 11748016. Created 7 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 | « runtime/lib/date_patch.dart ('k') | runtime/lib/integers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.dart
diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart
index decfb570389fea5f78f88785634a8c34bb868fbf..29247adb02c05c794bc74c09ba5d709fd5be3ce1 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -100,10 +100,15 @@ class _Double implements double {
return this < 0.0 ? -this : this;
}
- double round() native "Double_round";
- double floor() native "Double_floor";
- double ceil () native "Double_ceil";
- double truncate() native "Double_truncate";
+ int round() => roundToDouble().toInt();
+ int floor() => floorToDouble().toInt();
+ int ceil () => ceilToDouble().toInt();
+ int truncate() => truncateToDouble().toInt();
+
+ double roundToDouble() native "Double_round";
+ double floorToDouble() native "Double_floor";
+ double ceilToDouble() native "Double_ceil";
+ double truncateToDouble() native "Double_truncate";
srdjan 2013/02/26 16:35:26 Why not use roundToInt, and leave original semanti
floitsch 2013/02/26 17:44:35 That's already not the case: 5.2 ~/ 2.0 => 2
num clamp(num lowerLimit, num upperLimit) {
if (lowerLimit is! num) throw new ArgumentError(lowerLimit);
« no previous file with comments | « runtime/lib/date_patch.dart ('k') | runtime/lib/integers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698