Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Copyright 2009 The Go Authors. All rights reserved. | 5 // Copyright 2009 The Go Authors. All rights reserved. |
| 6 // Use of this source code is governed by a BSD-style | 6 // Use of this source code is governed by a BSD-style |
| 7 // license that can be found in the LICENSE file. | 7 // license that can be found in the LICENSE file. |
| 8 | 8 |
| 9 /* | 9 /* |
| 10 * Copyright (c) 2003-2005 Tom Wu | 10 * Copyright (c) 2003-2005 Tom Wu |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1555 if (inv) { | 1555 if (inv) { |
| 1556 if ((y_used == 1) && (y_digits[0] == 1)) return 1; | 1556 if ((y_used == 1) && (y_digits[0] == 1)) return 1; |
| 1557 if ((y_used == 0) || (y_digits[0].isEven && x_digits[0].isEven)) { | 1557 if ((y_used == 0) || (y_digits[0].isEven && x_digits[0].isEven)) { |
| 1558 throw new RangeError("Not coprime"); | 1558 throw new RangeError("Not coprime"); |
| 1559 } | 1559 } |
| 1560 } else { | 1560 } else { |
| 1561 if ((x_used == 0) || (y_used == 0)) throw new RangeError(0); | 1561 if ((x_used == 0) || (y_used == 0)) throw new RangeError(0); |
| 1562 if (((x_used == 1) && (x_digits[0] == 1)) || | 1562 if (((x_used == 1) && (x_digits[0] == 1)) || |
| 1563 ((y_used == 1) && (y_digits[0] == 1))) return 1; | 1563 ((y_used == 1) && (y_digits[0] == 1))) return 1; |
| 1564 bool xy_cloned = false; | 1564 bool xy_cloned = false; |
| 1565 while (x.isEven && y.isEven) { | 1565 while (x_digits[0].isEven && y_digits[0].isEven) { |
|
regis
2015/06/25 17:03:13
Thanks
You could even write ((x_digits[0] & 1) ==
Lasse Reichstein Nielsen
2015/06/26 08:40:40
Done.
Would it make sense to count the leading ze
| |
| 1566 _rsh(x_digits, x_used, 1, x_digits); | 1566 _rsh(x_digits, x_used, 1, x_digits); |
| 1567 _rsh(y_digits, y_used, 1, y_digits); | 1567 _rsh(y_digits, y_used, 1, y_digits); |
| 1568 s++; | 1568 s++; |
| 1569 } | 1569 } |
| 1570 if (s >= _DIGIT_BITS) { | 1570 if (s >= _DIGIT_BITS) { |
| 1571 var sd = s >> _LOG2_DIGIT_BITS; | 1571 var sd = s >> _LOG2_DIGIT_BITS; |
| 1572 x_used -= sd; | 1572 x_used -= sd; |
| 1573 y_used -= sd; | 1573 y_used -= sd; |
| 1574 m_used -= sd; | 1574 m_used -= sd; |
| 1575 } | 1575 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2070 | 2070 |
| 2071 int _mul(Uint32List x_digits, int x_used, | 2071 int _mul(Uint32List x_digits, int x_used, |
| 2072 Uint32List y_digits, int y_used, | 2072 Uint32List y_digits, int y_used, |
| 2073 Uint32List r_digits) { | 2073 Uint32List r_digits) { |
| 2074 var r_used = _Bigint._mulDigits(x_digits, x_used, | 2074 var r_used = _Bigint._mulDigits(x_digits, x_used, |
| 2075 y_digits, y_used, | 2075 y_digits, y_used, |
| 2076 r_digits); | 2076 r_digits); |
| 2077 return _reduce(r_digits, r_used); | 2077 return _reduce(r_digits, r_used); |
| 2078 } | 2078 } |
| 2079 } | 2079 } |
| OLD | NEW |