(self)
| 168 | self.assertTrue(y < r <= 0, "bad mod from divmod") |
| 169 | |
| 170 | def test_division(self): |
| 171 | digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF, |
| 172 | KARATSUBA_CUTOFF + 14)) |
| 173 | digits.append(KARATSUBA_CUTOFF * 3) |
| 174 | for lenx in digits: |
| 175 | x = self.getran(lenx) |
| 176 | for leny in digits: |
| 177 | y = self.getran(leny) or 1 |
| 178 | self.check_division(x, y) |
| 179 | |
| 180 | # specific numbers chosen to exercise corner cases of the |
| 181 | # current long division implementation |
| 182 | |
| 183 | # 30-bit cases involving a quotient digit estimate of BASE+1 |
| 184 | self.check_division(1231948412290879395966702881, |
| 185 | 1147341367131428698) |
| 186 | self.check_division(815427756481275430342312021515587883, |
| 187 | 707270836069027745) |
| 188 | self.check_division(627976073697012820849443363563599041, |
| 189 | 643588798496057020) |
| 190 | self.check_division(1115141373653752303710932756325578065, |
| 191 | 1038556335171453937726882627) |
| 192 | # 30-bit cases that require the post-subtraction correction step |
| 193 | self.check_division(922498905405436751940989320930368494, |
| 194 | 949985870686786135626943396) |
| 195 | self.check_division(768235853328091167204009652174031844, |
| 196 | 1091555541180371554426545266) |
| 197 | |
| 198 | # 15-bit cases involving a quotient digit estimate of BASE+1 |
| 199 | self.check_division(20172188947443, 615611397) |
| 200 | self.check_division(1020908530270155025, 950795710) |
| 201 | self.check_division(128589565723112408, 736393718) |
| 202 | self.check_division(609919780285761575, 18613274546784) |
| 203 | # 15-bit cases that require the post-subtraction correction step |
| 204 | self.check_division(710031681576388032, 26769404391308) |
| 205 | self.check_division(1933622614268221, 30212853348836) |
| 206 | |
| 207 | |
| 208 |
nothing calls this directly
no test coverage detected