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

Side by Side Diff: pkg/fixnum/lib/src/int32.dart

Issue 875323002: Cleanup IntX to implement Comparable<FixNum> which is more descriptive than Comparable as it would … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/fixnum/lib/src/int64.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of fixnum; 5 part of fixnum;
6 6
7 /** 7 /**
8 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. 8 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1].
9 * Arithmetic operations may overflow in order to maintain this range. 9 * Arithmetic operations may overflow in order to maintain this range.
10 */ 10 */
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (other is Int32) { 277 if (other is Int32) {
278 return _i == other._i; 278 return _i == other._i;
279 } else if (other is Int64) { 279 } else if (other is Int64) {
280 return this.toInt64() == other; 280 return this.toInt64() == other;
281 } else if (other is int) { 281 } else if (other is int) {
282 return _i == other; 282 return _i == other;
283 } 283 }
284 return false; 284 return false;
285 } 285 }
286 286
287 int compareTo(Comparable other) { 287 int compareTo(IntX other) {
288 if (other is Int64) { 288 if (other is Int64) {
289 return this.toInt64().compareTo(other); 289 return this.toInt64().compareTo(other);
290 } 290 }
291 return _i.compareTo(_toInt(other)); 291 return _i.compareTo(_toInt(other));
292 } 292 }
293 293
294 bool operator <(other) { 294 bool operator <(other) {
295 if (other is Int64) { 295 if (other is Int64) {
296 return this.toInt64() < other; 296 return this.toInt64() < other;
297 } 297 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 368
369 double toDouble() => _i.toDouble(); 369 double toDouble() => _i.toDouble();
370 int toInt() => _i; 370 int toInt() => _i;
371 Int32 toInt32() => this; 371 Int32 toInt32() => this;
372 Int64 toInt64() => new Int64(_i); 372 Int64 toInt64() => new Int64(_i);
373 373
374 String toString() => _i.toString(); 374 String toString() => _i.toString();
375 String toHexString() => _i.toRadixString(16); 375 String toHexString() => _i.toRadixString(16);
376 String toRadixString(int radix) => _i.toRadixString(radix); 376 String toRadixString(int radix) => _i.toRadixString(radix);
377 } 377 }
OLDNEW
« no previous file with comments | « no previous file | pkg/fixnum/lib/src/int64.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698