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

Unified Diff: sdk/lib/_internal/lib/js_number.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 | « runtime/lib/integers.dart ('k') | sdk/lib/core/double.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_number.dart
diff --git a/sdk/lib/_internal/lib/js_number.dart b/sdk/lib/_internal/lib/js_number.dart
index b6606f0699d05bc69b78691e46792946ac2ba618..7aaeb9369e78d33e73bd942db52a1188101ddcff 100644
--- a/sdk/lib/_internal/lib/js_number.dart
+++ b/sdk/lib/_internal/lib/js_number.dart
@@ -59,6 +59,8 @@ class JSNumber extends Interceptor implements num {
num abs() => JS('num', r'Math.abs(#)', this);
+ num get sign => this > 0 ? 1 : this < 0 ? -1 : this;
Søren Gjesse 2013/12/13 11:45:04 EcmaScript 6 has Math.sign with the same semantics
Lasse Reichstein Nielsen 2013/12/13 12:08:48 Interesting. Did not know that. Since it most like
+
static const int _MIN_INT32 = -0x80000000;
static const int _MAX_INT32 = 0x7FFFFFFF;
@@ -240,7 +242,7 @@ class JSNumber extends Interceptor implements num {
}
num operator >>(num other) {
- if (false) _shrReceiverPositive(other);
+ if (false) _shrReceiverPositive(other);
sra1 2014/03/07 00:53:35 What is the purpose of this dead code? Please dele
if (other is !num) throw new ArgumentError(other);
if (JS('num', '#', other) < 0) throw new ArgumentError(other);
return _shrOtherPositive(other);
« no previous file with comments | « runtime/lib/integers.dart ('k') | sdk/lib/core/double.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698