Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of negative exponentiation inconsistent between integer types #7648

Closed
jakevdp opened this issue May 19, 2016 · 5 comments
Closed

Comments

@jakevdp
Copy link
Contributor

jakevdp commented May 19, 2016

>>> np.int64(2) ** -2
0.25
>>> np.int32(2) ** -2
0

Tested on OSX 10.8.5 w/ numpy 1.10 on both Python 2.7 and 3.5.

@navneethc
Copy link

I second this.

Following tested using:
Python 3.5.1 (Python 3 environment created using Anaconda 4 64-bit)
Numpy 1.11.0

In [34]: np.int32(2)**-2
Out[34]: 0.25

In [35]: np.uint32(2)**-2
Out[35]: 0

In [36]: np.int64(2)**-2
Out[36]: 0.25

In [37]: np.uint64(2)**-2
Out[37]: 0.25

In [38]: np.int16(2)**-2
Out[38]: 0

In [39]: np.uint16(2)**-2
Out[39]: 0

In [40]: np.int8(2)**-2
Out[40]: 0

In [41]: np.uint8(2)**-2
Out[41]: 0

@ewmoore
Copy link
Contributor

ewmoore commented May 19, 2016

See issue #7449 and PR #7459. The PR fixes this, but could use some review.

@mhvk
Copy link
Contributor

mhvk commented May 19, 2016

Just in case (have to run): Note that the array case should also keep working. In numpy 1.11:

np.ones((2,), dtype=int) ** -2
# array([1, 1])

In current master:

np.ones((2,), dtype=int) ** -2
# array([0, 0])

@ewmoore
Copy link
Contributor

ewmoore commented May 19, 2016

Gah. That's mine.

@ewmoore
Copy link
Contributor

ewmoore commented May 19, 2016

See #7651.

@charris charris added this to the 1.11.1 release milestone May 19, 2016
@charris charris removed this from the 1.11.1 release milestone May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants