# [Numpy-discussion] Integers to negative integer powers, time for a decision.

Krisztián Horváth raksi.raksi at gmail.com
Sun Oct 9 06:42:44 EDT 2016

```> Sounds good to me. I agree that we should prioritize within-numpy
> consistency over consistency with Python.
>

I agree with that. Because of numpy consitetncy, the `**` operator should
always return float. Right now the case is:

>>> aa = np.arange(2, 10, dtype=int)
array([2, 3, 4, 5, 6, 7, 8, 9])

>>> bb = np.linspace(0, 7, 8, dtype=int)
array([0, 1, 2, 3, 4, 5, 6, 7])

>>> 1/aa
array([ 0.5       ,  0.33333333,  0.25      ,  0.2       ,  0.16666667,
0.14285714,  0.125     ,  0.11111111])

>>> aa**-1
array([0, 0, 0, 0, 0, 0, 0, 0])

>>> 1/aa**2
array([ 0.25      ,  0.11111111,  0.0625    ,  0.04      ,  0.02777778,
0.02040816,  0.015625  ,  0.01234568])

>>> aa**-2
array([0, 0, 0, 0, 0, 0, 0, 0])

>>> aa**bb
array([      1,       3,      16,     125,    1296,   16807,  262144,
4782969])

>>> 1/aa**bb
array([  1.00000000e+00,   3.33333333e-01,   6.25000000e-02,
8.00000000e-03,   7.71604938e-04,   5.94990183e-05,
3.81469727e-06,   2.09075158e-07])

>>> aa**(-bb)
array([1, 0, 0, 0, 0, 0, 0, 0])

For me this behaviour is confusing. But I am not an expert just a user. I
can live together with anything if I know what to expect. And I greatly
appreciate the work of any developer for this excellent package.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161009/55ce0493/attachment.html>
```