| 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 /** | 5 /** |
| 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. | 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. |
| 7 * Arithmetic operations may overflow in order to maintain this range. | 7 * Arithmetic operations may overflow in order to maintain this range. |
| 8 */ | 8 */ |
| 9 class int32 implements intx { | 9 class int32 implements intx { |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return new int32.fromInt(_i + _convert(other)); | 171 return new int32.fromInt(_i + _convert(other)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 intx operator -(other) { | 174 intx operator -(other) { |
| 175 if (other is int64) { | 175 if (other is int64) { |
| 176 return this.toInt64() - other; | 176 return this.toInt64() - other; |
| 177 } | 177 } |
| 178 return new int32.fromInt(_i - _convert(other)); | 178 return new int32.fromInt(_i - _convert(other)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 int32 operator negate() => new int32.fromInt(-_i); | 181 int32 operator -() => new int32.fromInt(-_i); |
| 182 | 182 |
| 183 intx operator *(other) { | 183 intx operator *(other) { |
| 184 if (other is int64) { | 184 if (other is int64) { |
| 185 return this.toInt64() * other; | 185 return this.toInt64() * other; |
| 186 } | 186 } |
| 187 // TODO(rice) - optimize | 187 // TODO(rice) - optimize |
| 188 return (this.toInt64() * other).toInt32(); | 188 return (this.toInt64() * other).toInt32(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 int32 operator %(other) { | 191 int32 operator %(other) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 int toInt() => _i; | 347 int toInt() => _i; |
| 348 int32 toInt32() => this; | 348 int32 toInt32() => this; |
| 349 int64 toInt64() => new int64.fromInt(_i); | 349 int64 toInt64() => new int64.fromInt(_i); |
| 350 | 350 |
| 351 String toString() => _i.toString(); | 351 String toString() => _i.toString(); |
| 352 String toHexString() => _i.toRadixString(16); | 352 String toHexString() => _i.toRadixString(16); |
| 353 String toRadixString(int radix) => _i.toRadixString(radix); | 353 String toRadixString(int radix) => _i.toRadixString(radix); |
| 354 } | 354 } |
| OLD | NEW |