| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 int value; | 263 int value; |
| 264 if (_i >= 0) { | 264 if (_i >= 0) { |
| 265 value = _i >> n; | 265 value = _i >> n; |
| 266 } else { | 266 } else { |
| 267 value = (_i >> n) & ((1 << (32 - n)) - 1); | 267 value = (_i >> n) & ((1 << (32 - n)) - 1); |
| 268 } | 268 } |
| 269 return new Int32(value); | 269 return new Int32(value); |
| 270 } | 270 } |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * Returns [true] if this [Int32] has the same numeric value as the | 273 * Returns [:true:] if this [Int32] has the same numeric value as the |
| 274 * given object. The argument may be an [int] or an [IntX]. | 274 * given object. The argument may be an [int] or an [IntX]. |
| 275 */ | 275 */ |
| 276 bool operator ==(other) { | 276 bool operator ==(other) { |
| 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 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |