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

Unified Diff: runtime/lib/double.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
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | sdk/lib/_internal/lib/js_number.dart » ('J')
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 c5b2c38156fadf276781a60003f152997041159b..8efe789865fccc5b3150c4336f5db26d05fc7cd5 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -104,6 +104,12 @@ class _Double implements double {
return this < 0.0 ? -this : this;
}
+ double get sign {
+ if (this > 0.0) return 1.0;
+ if (this < 0.0) return -1.0;
+ return this; // +/-0.0 or NaN.
+ }
+
int round() => roundToDouble().toInt();
int floor() => floorToDouble().toInt();
int ceil () => ceilToDouble().toInt();
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | sdk/lib/_internal/lib/js_number.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698