| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 final int _i; | 131 final int _i; |
| 132 | 132 |
| 133 const Int32._internal(int i) : _i = i; | 133 const Int32._internal(int i) : _i = i; |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * Constructs an [Int32] from an [int]. Only the low 32 bits of the input | 136 * Constructs an [Int32] from an [int]. Only the low 32 bits of the input |
| 137 * are used. | 137 * are used. |
| 138 */ | 138 */ |
| 139 Int32([int i=0]) : _i = (i & 0x7fffffff) - (i & 0x80000000); | 139 Int32([int i=0]) : _i = (i & 0x7fffffff) - (i & 0x80000000); |
| 140 | 140 |
| 141 /** | |
| 142 * Constructs an [Int32] from an [int]. Only the low 32 bits of the input | |
| 143 * are used. | |
| 144 */ | |
| 145 @deprecated | |
| 146 Int32.fromInt(int i) : this(i); | |
| 147 | |
| 148 // Returns the [int] representation of the specified value. Throws | 141 // Returns the [int] representation of the specified value. Throws |
| 149 // [ArgumentError] for non-integer arguments. | 142 // [ArgumentError] for non-integer arguments. |
| 150 int _toInt(val) { | 143 int _toInt(val) { |
| 151 if (val is Int32) { | 144 if (val is Int32) { |
| 152 return val._i; | 145 return val._i; |
| 153 } else if (val is int) { | 146 } else if (val is int) { |
| 154 return val; | 147 return val; |
| 155 } | 148 } |
| 156 throw new ArgumentError(val); | 149 throw new ArgumentError(val); |
| 157 } | 150 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 368 |
| 376 double toDouble() => _i.toDouble(); | 369 double toDouble() => _i.toDouble(); |
| 377 int toInt() => _i; | 370 int toInt() => _i; |
| 378 Int32 toInt32() => this; | 371 Int32 toInt32() => this; |
| 379 Int64 toInt64() => new Int64(_i); | 372 Int64 toInt64() => new Int64(_i); |
| 380 | 373 |
| 381 String toString() => _i.toString(); | 374 String toString() => _i.toString(); |
| 382 String toHexString() => _i.toRadixString(16); | 375 String toHexString() => _i.toRadixString(16); |
| 383 String toRadixString(int radix) => _i.toRadixString(radix); | 376 String toRadixString(int radix) => _i.toRadixString(radix); |
| 384 } | 377 } |
| OLD | NEW |