| 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 64-bit signed integer, in the range [-2^63, 2^63 - 1]. | 6 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 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 int64 implements intx { | 9 class int64 implements intx { |
| 10 | 10 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 int64 o = _promote(other); | 266 int64 o = _promote(other); |
| 267 | 267 |
| 268 int sum0 = _l - o._l; | 268 int sum0 = _l - o._l; |
| 269 int sum1 = _m - o._m + _shiftRight(sum0, _BITS); | 269 int sum1 = _m - o._m + _shiftRight(sum0, _BITS); |
| 270 int sum2 = _h - o._h + _shiftRight(sum1, _BITS); | 270 int sum2 = _h - o._h + _shiftRight(sum1, _BITS); |
| 271 | 271 |
| 272 int64 result = new int64._bits(sum0 & _MASK, sum1 & _MASK, sum2 & _MASK_2); | 272 int64 result = new int64._bits(sum0 & _MASK, sum1 & _MASK, sum2 & _MASK_2); |
| 273 return result; | 273 return result; |
| 274 } | 274 } |
| 275 | 275 |
| 276 int64 operator negate() { | 276 int64 operator -() { |
| 277 // Like 0 - this. | 277 // Like 0 - this. |
| 278 int sum0 = -_l; | 278 int sum0 = -_l; |
| 279 int sum1 = -_m + _shiftRight(sum0, _BITS); | 279 int sum1 = -_m + _shiftRight(sum0, _BITS); |
| 280 int sum2 = -_h + _shiftRight(sum1, _BITS); | 280 int sum2 = -_h + _shiftRight(sum1, _BITS); |
| 281 | 281 |
| 282 return new int64._bits(sum0 & _MASK, sum1 & _MASK, sum2 & _MASK_2); | 282 return new int64._bits(sum0 & _MASK, sum1 & _MASK, sum2 & _MASK_2); |
| 283 } | 283 } |
| 284 | 284 |
| 285 int64 operator *(other) { | 285 int64 operator *(other) { |
| 286 int64 o = _promote(other); | 286 int64 o = _promote(other); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 return ZERO; | 1088 return ZERO; |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 // Generate the quotient using bit-at-a-time long division. | 1091 // Generate the quotient using bit-at-a-time long division. |
| 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, | 1092 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, |
| 1093 aIsNegative, aIsMinValue, computeRemainder); | 1093 aIsNegative, aIsMinValue, computeRemainder); |
| 1094 } | 1094 } |
| 1095 } | 1095 } |
| OLD | NEW |