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

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

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 12 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
Index: sdk/lib/core/num.dart
diff --git a/sdk/lib/core/num.dart b/sdk/lib/core/num.dart
index 44bc09a7250b1c14f6bc339da49b601fb5c4b104..29f0d6c6e52615c003cb864f9e78a1a7e009e24e 100644
--- a/sdk/lib/core/num.dart
+++ b/sdk/lib/core/num.dart
@@ -31,7 +31,7 @@ abstract class num implements Comparable {
*/
// TODO(floitsch): this is currently not true: bignum1 / bignum2 will return
// NaN, whereas bignum1 ~/ bignum2 will give the correct result.
- num operator ~/(num other);
+ int operator ~/(num other);
/** Negate operator. */
num operator -();
@@ -60,25 +60,32 @@ abstract class num implements Comparable {
/** Returns the absolute value of this [num]. */
num abs();
- /** Returns the greatest integer value no greater than this [num]. */
- num floor();
+ /**
+ * Returns the greatest integer no greater than [this] Throws a
Lasse Reichstein Nielsen 2013/01/04 10:29:42 Missing '.'. Two newlines after the '.'.
+ * [FormatException] if [this] cannot be converted.
+ */
+ int floor();
- /** Returns the least integer value that is no smaller than this [num]. */
- num ceil();
+ /**
+ * Returns the least integer that is no smaller than [this]. Throws a
Lasse Reichstein Nielsen 2013/01/04 10:29:42 Two newlines after '.'.
+ * [FormatException] if [this] cannot be converted.
+ */
+ int ceil();
/**
- * Returns the integer value closest to this [num].
+ * Returns the integer closest to [this]. Throws a [FormatException] if
+ * [this] cannot be converted.
*
* Rounds away from zero when there is no closest integer:
* [:(3.5).round() == 4:] and [:(-3.5).round() == -4:].
*/
- num round();
+ int round();
/**
- * Returns the integer value obtained by discarding any fractional
- * digits from this [num].
+ * Returns the integer obtained by discarding any fractional digits from
+ * [this]. Throws a [FormatException] if [this] cannot be converted.
*/
- num truncate();
+ int truncate();
/**
* Clamps [this] to be in the range [lowerLimit]-[upperLimit]. The comparison
@@ -87,9 +94,6 @@ abstract class num implements Comparable {
*/
num clamp(num lowerLimit, num upperLimit);
- /** Truncates this [num] to an integer and returns the result as an [int]. */
- int toInt();
-
/**
* Return this [num] as a [double].
*

Powered by Google App Engine
This is Rietveld 408576698