Weird behaviour of np.sqrt for very large integers
问题 >>> np.__version__ '1.7.0' >>> np.sqrt(10000000000000000000) 3162277660.1683793 >>> np.sqrt(100000000000000000000.) 10000000000.0 >>> np.sqrt(100000000000000000000) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: sqrt Huh... AttributeError: sqrt what's going on here then? math.sqrt doesn't seem to have the same problem. 回答1: The final number is a long (Python's name for an arbitrary precision integer), which NumPy apparently can't deal with: >>> type