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

Unified Diff: runtime/lib/integers.dart

Issue 10692099: Fix int.compareTo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | tests/corelib/compare_to_test.dart » ('j') | tests/corelib/compare_to_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/integers.dart
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart
index c1a79c8f843e7f9a4c9e596090f43dd603d19196..f2eaf9f645c762cfb51bac88c99937c5e2cf486e 100644
--- a/runtime/lib/integers.dart
+++ b/runtime/lib/integers.dart
@@ -97,15 +97,16 @@ class IntegerImplementation {
int compareTo(Comparable other) {
Lasse Reichstein Nielsen 2012/07/06 08:56:17 Argh. Why did we not define Comparable to be gener
floitsch 2012/07/06 13:18:55 Changing to num now, and adding generic type to co
final int EQUAL = 0, LESS = -1, GREATER = 1;
+ if (other is double) {
+ // Let the double implementation deal with -0.0 and NaN.
+ return -other.compareTo(this.toDouble());
Lasse Reichstein Nielsen 2012/07/06 08:56:17 I think that's wrong. If this is, e.g., 1<<2000 (a
floitsch 2012/07/06 13:18:55 Done.
+ }
if (this < other) {
return LESS;
} else if (this > other) {
return GREATER;
- } else if (this == other) {
- return EQUAL;
} else {
- // Other is NaN.
- return LESS;
+ return EQUAL;
}
}
« no previous file with comments | « no previous file | tests/corelib/compare_to_test.dart » ('j') | tests/corelib/compare_to_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698