Why does numpy.power return 0 for small exponents while math.pow returns the correct answer?

后端 未结 3 894
感动是毒
感动是毒 2021-01-17 09:21
In [25]: np.power(10,-100)
Out[25]: 0

In [26]: math.pow(10,-100)
Out[26]: 1e-100

I would expect both the commands to return 1e-100. This is not a

3条回答
  •  没有蜡笔的小新
    2021-01-17 09:58

    numpy method assumes you want integer returned since you supplied an integer.

    np.power(10.0,-100) 
    

    works as you would expect.

提交回复
热议问题