FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: Fix divmod by charris · Pull Request #7022 · numpy/numpy · GitHub

Repository navigation

BUG: Fix divmod - #7022

Merged
charris merged 2 commits into
numpy:masterfrom
charris:fix-divmod
Jan 16, 2016
Merged

charris merged 2 commits into
numpy:masterfrom
charris:fix-divmod

Conversation

charris commented Jan 15, 2016

Copy link
Copy Markdown
Member

Fix the remainder function so that it is consistent with floor_division.

Instead of using the C % operator, this PR computes remainder(a, b) as

b * (a/b - floor(a/b)),

which is consistent with implementing floor_division(a, b) as floor(a/b) and numerically better behaved than the implementation

a - b*floor(a/b).

Closes #6127.

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.
charris added this to the 1.11.0 release milestone Jan 15, 2016
charris changed the title Fix divmod BUG: Fix divmod Jan 16, 2016
charris added a commit that referenced this pull request Jan 16, 2016
charris merged commit 115975e into numpy:master Jan 16, 2016
charris deleted the fix-divmod branch January 16, 2016 22:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL