| OLD | NEW |
| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 bool operator ==(other) { | 281 bool operator ==(other) { |
| 282 if (other == null) { | 282 if (other == null) { |
| 283 return false; | 283 return false; |
| 284 } | 284 } |
| 285 if (other is int64) { | 285 if (other is int64) { |
| 286 return this.toInt64() == other; | 286 return this.toInt64() == other; |
| 287 } | 287 } |
| 288 return _i == _convert(other); | 288 return _i == _convert(other); |
| 289 } | 289 } |
| 290 | 290 |
| 291 int compareTo(other) { | 291 int compareTo(Comparable other) { |
| 292 if (other is int64) { | 292 if (other is int64) { |
| 293 return this.toInt64().compareTo(other); | 293 return this.toInt64().compareTo(other); |
| 294 } | 294 } |
| 295 return _i.compareTo(_convert(other)); | 295 return _i.compareTo(_convert(other)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool operator <(other) { | 298 bool operator <(other) { |
| 299 if (other is int64) { | 299 if (other is int64) { |
| 300 return this.toInt64() < other; | 300 return this.toInt64() < other; |
| 301 } | 301 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 331 bool get isZero => _i == 0; | 331 bool get isZero => _i == 0; |
| 332 | 332 |
| 333 int get hashCode => _i; | 333 int get hashCode => _i; |
| 334 | 334 |
| 335 int32 abs() => _i < 0 ? new int32.fromInt(-_i) : this; | 335 int32 abs() => _i < 0 ? new int32.fromInt(-_i) : this; |
| 336 | 336 |
| 337 int numberOfLeadingZeros() => _numberOfLeadingZeros(_i); | 337 int numberOfLeadingZeros() => _numberOfLeadingZeros(_i); |
| 338 int numberOfTrailingZeros() => _numberOfTrailingZeros(_i); | 338 int numberOfTrailingZeros() => _numberOfTrailingZeros(_i); |
| 339 | 339 |
| 340 List<int> toBytes() { | 340 List<int> toBytes() { |
| 341 List<int> result = new List<int>.fixedLength(4); | 341 List<int> result = new List<int>(4); |
| 342 result[0] = _i & 0xff; | 342 result[0] = _i & 0xff; |
| 343 result[1] = (_i >> 8) & 0xff; | 343 result[1] = (_i >> 8) & 0xff; |
| 344 result[2] = (_i >> 16) & 0xff; | 344 result[2] = (_i >> 16) & 0xff; |
| 345 result[3] = (_i >> 24) & 0xff; | 345 result[3] = (_i >> 24) & 0xff; |
| 346 return result; | 346 return result; |
| 347 } | 347 } |
| 348 | 348 |
| 349 int toInt() => _i; | 349 int toInt() => _i; |
| 350 int32 toInt32() => this; | 350 int32 toInt32() => this; |
| 351 int64 toInt64() => new int64.fromInt(_i); | 351 int64 toInt64() => new int64.fromInt(_i); |
| 352 | 352 |
| 353 String toString() => _i.toString(); | 353 String toString() => _i.toString(); |
| 354 String toHexString() => _i.toRadixString(16); | 354 String toHexString() => _i.toRadixString(16); |
| 355 String toRadixString(int radix) => _i.toRadixString(radix); | 355 String toRadixString(int radix) => _i.toRadixString(radix); |
| 356 } | 356 } |
| OLD | NEW |