numpy版本1.9.0
1 & (2**63)
0
np.bitwise_and(1, 2**63)
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
np.bitwise_and(1, 2**63 + 100)
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
np.bitwise_and(1, 2**64)
0
这是虫子还是我遗漏了什么?
首先转换为
uint64
:下面是检查将python integer转换为numpy integer的规则的代码:
输出:
我认为
np.bitwise_and(1, 2**63)
引发错误是因为2**63
超出了int32和int64的范围。np.bitwise_and(1, 2**64)
工作,因为它将使用Python的长对象。我们需要阅读源代码来理解细节。
相关问题 更多 >
编程相关推荐