BUG: Prevent power(uint64, int64) casting to float - #8853
Closed
eric-wieser wants to merge 1 commit into
Closed
Conversation
This was referenced Mar 27, 2017
Partials resolves numpy#8809 Previously, the signatures were: * power(int, int) -> int * power(uint, uint) -> uint. Since we forbid the second argument from being negative, we can also define * power(int, uint) -> int: same as power(int, int), without an error check * power(uint, int) -> uint: same as power(uint, uint), with an error check If we do not define these, then the signature used is: * t = common(int, uint); power(t, t) -> t: This is bad, because common(int64, uint64) is float
eric-wieser
force-pushed
the
power-mixed-sign
branch
from
March 27, 2017 22:24
32eb345 to
fee4481
Compare
Contributor
|
☔ The latest upstream changes (presumably #9015) made this pull request unmergeable. Please resolve the merge conflicts. |
Member
|
This makes sense, probably need a list posting on account of the behavior change. Also needs a rebase. |
Member
|
Looks like the release note needs to be moved to |
Member
Author
|
There's also the question of whether we should make this a wider-sweeping change for all int/uint arithmetic. |
Member
|
This needs a freshening-up, and the release note needs to move forward. I think the example should go to the |
Member
|
@eric-wieser Needs rebase. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partials resolves #8809
Previously, the signatures were:
power(int, int) -> intpower(uint, uint) -> uintSo when we pass a mixture of
intanduint, we find a common typet = common(int, uint), and invokepower(t, t) -> t.This is bad, because
common(int64, uint64)isfloat64This PR defines:
power(int, uint) -> intsame as
power(int, int), without an error checkpower(uint, int) -> uint:same as
power(uint, uint), with an error checkObviously, there is a cost associated with reducing the size of the output type - overflows happen sooner.
But what we have right now is inconsistent - from a mathematical perspective
power(uint, int)has a strictly smaller range of values that can be produced thanpower(uint, uint)- so why do we allocate a larger output type for it?