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

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

Issue 113833002: Add num.sign getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed to return same type as the number (double for doubles, int for ints). Returns -0.0 for -0.0… Created 7 years 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 7e4bf454d1866a1d5fa56d17b557b5a11764e9b9..fc89d65c8ae5b3a80199697ded48d8d7407410a2 100644
--- a/sdk/lib/core/num.dart
+++ b/sdk/lib/core/num.dart
@@ -170,6 +170,27 @@ abstract class num implements Comparable<num> {
num abs();
/**
+ * Returns minus one, zero or plus one depending on the sign and
+ * numerical value of the number.
+ *
+ * Returns minus one if the number is less than zero,
+ * plus one if the number is greater than zero,
+ * and zero if the number is equal to zero.
+ *
+ * Returns NaN if the number is the double NaN value.
+ *
+ * Returns a number of the same type as this number.
+ * For doubles, `-0.0.sign == -0.0`.
+
+ * The result satisfies:
+ *
+ * n == n.sign * n.abs()
+ *
+ * for all numbers `n` (except NaN, because NaN isn't `==` to itself).
+ */
+ num get sign;
+
+ /**
* Returns the integer closest to `this`.
*
* Rounds away from zero when there is no closest integer:

Powered by Google App Engine
This is Rietveld 408576698