Helper function for _div2n1n; not intended to be called directly.
(a12, a3, b, b1, b2, n)
| 450 | |
| 451 | |
| 452 | def _div3n2n(a12, a3, b, b1, b2, n): |
| 453 | """Helper function for _div2n1n; not intended to be called directly.""" |
| 454 | if a12 >> n == b1: |
| 455 | q, r = (1 << n) - 1, a12 - (b1 << n) + b1 |
| 456 | else: |
| 457 | q, r = _div2n1n(a12, b1, n) |
| 458 | r = (r << n | a3) - q * b2 |
| 459 | while r < 0: |
| 460 | q -= 1 |
| 461 | r += b |
| 462 | return q, r |
| 463 | |
| 464 | |
| 465 | def _int2digits(a, n): |