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

Unified Diff: runtime/lib/integers.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: runtime/lib/integers.dart
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart
index 7f7fc90c259314cf8c4d34c2df54bbfa478d91ae..9c503c4b775bf56c11391182b094a4bd1c7afa9b 100644
--- a/runtime/lib/integers.dart
+++ b/runtime/lib/integers.dart
@@ -92,6 +92,9 @@ class _IntegerImplementation {
int abs() {
return this < 0 ? -this : this;
}
+ int get sign {
+ return (this > 0) ? 1 : (this < 0) ? -1 : 0;
+ }
bool get isEven => ((this & 1) == 0);
bool get isOdd => !isEven;
bool get isNaN => false;

Powered by Google App Engine
This is Rietveld 408576698