| 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 64-bit signed integer, in the range [-2^63, 2^63 - 1]. | 8 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 | 787 |
| 788 q = d1 ~/ fatRadix; | 788 q = d1 ~/ fatRadix; |
| 789 r = d1 - q * fatRadix; | 789 r = d1 - q * fatRadix; |
| 790 d1 = q; | 790 d1 = q; |
| 791 d0 += r << 10; | 791 d0 += r << 10; |
| 792 | 792 |
| 793 q = d0 ~/ fatRadix; | 793 q = d0 ~/ fatRadix; |
| 794 r = d0 - q * fatRadix; | 794 r = d0 - q * fatRadix; |
| 795 d0 = q; | 795 d0 = q; |
| 796 | 796 |
| 797 assert(chunk2 == ""); | 797 assert(chunk3 == ""); |
| 798 chunk3 = chunk2; | 798 chunk3 = chunk2; |
| 799 chunk2 = chunk1; | 799 chunk2 = chunk1; |
| 800 // Adding [fatRadix] Forces an extra digit which we discard to get a fixed | 800 // Adding [fatRadix] Forces an extra digit which we discard to get a fixed |
| 801 // width. E.g. (1000000 + 123) -> "1000123" -> "000123". An alternative | 801 // width. E.g. (1000000 + 123) -> "1000123" -> "000123". An alternative |
| 802 // would be to pad to the left with zeroes. | 802 // would be to pad to the left with zeroes. |
| 803 chunk1 = (fatRadix + r).toRadixString(radix).substring(1); | 803 chunk1 = (fatRadix + r).toRadixString(radix).substring(1); |
| 804 } | 804 } |
| 805 int residue = (d2 << 20) + (d1 << 10) + d0; | 805 int residue = (d2 << 20) + (d1 << 10) + d0; |
| 806 String leadingDigits = residue == 0 ? '' : residue.toRadixString(radix); | 806 String leadingDigits = residue == 0 ? '' : residue.toRadixString(radix); |
| 807 return '$sign$leadingDigits$chunk1$chunk2$chunk3'; | 807 return '$sign$leadingDigits$chunk1$chunk2$chunk3'; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 } | 1193 } |
| 1194 } | 1194 } |
| 1195 return ZERO; | 1195 return ZERO; |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 // Generate the quotient using bit-at-a-time long division. | 1198 // Generate the quotient using bit-at-a-time long division. |
| 1199 return _divModHelper(aIsCopy ? a : new Int64._copy(a), b, negative, | 1199 return _divModHelper(aIsCopy ? a : new Int64._copy(a), b, negative, |
| 1200 aIsNegative, aIsMinValue, computeRemainder); | 1200 aIsNegative, aIsMinValue, computeRemainder); |
| 1201 } | 1201 } |
| 1202 } | 1202 } |
| OLD | NEW |