[Numpy-discussion] Integers to integer powers, let's make a decision

Antoine Pitrou solipsis at pitrou.net
Mon Jun 13 11:25:21 EDT 2016


On Mon, 13 Jun 2016 10:49:44 -0400
josef.pktd at gmail.com wrote:
> 
> My argument is that `**` is like integer division and sqrt where the domain
> where integer return are the correct numbers is too small to avoid
> headaches by users.

float64 has less integer precision than int64:

>>> math.pow(3, 39) == 3**39
False
>>> np.int64(3)**39 == 3**39
True


(as a sidenote, np.float64's equality operator seems to be slightly
broken:

>>> np.float64(3)**39 == 3**39
True
>>> int(np.float64(3)**39) == 3**39
False
>>> float(np.float64(3)**39) == 3**39
False
)

Regards

Antoine.





More information about the NumPy-Discussion mailing list