Repository navigation
Commit d213067
BUG: Make divmod behave better under roundoff error.
This is apropos numpy#6127. The fix is to make the functions floor_division
and remainder consistent, i.e.,
b * floor_division(a, b) + remainder(a, b) == a
Previous to this fix remainder was computed a the C level using the '%'
operator, and the result was not always consistent with the floor
function. The current approach is to compute the remainder using
b * (a/b - floor(a/b))
which is both consistent with the Python '%' operator and numerically
consistent with floor_division implemented using the floor function.
Closes numpy#6127.1 parent 9530bd9 commit d213067
2 files changed
Lines changed: 11 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1688 | 1688 | | |
1689 | 1689 | | |
1690 | 1690 | | |
1691 | | - | |
1692 | | - | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
| 1691 | + | |
| 1692 | + | |
1698 | 1693 | | |
1699 | 1694 | | |
1700 | 1695 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
| 346 | + | |
| 347 | + | |
352 | 348 | | |
353 | 349 | | |
354 | 350 | | |
355 | 351 | | |
356 | 352 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
363 | 356 | | |
364 | 357 | | |
365 | 358 | | |
| |||
0 commit comments