0
谁能解释这Python代码如何:左移一个Python整数产生不正确的结果
print "bits_received:", bits_received
tmp = 0
print type(tmp)
tmp = (1 << bits_received)
print type(tmp)
print "tmp: 0x{:X}".format(tmp)
会产生这样的结果:
bits_received: 95
<type 'int'>
<type 'numpy.int64'>
tmp: 0x80000000
'bits_received'是一个NumPy标量。 NumPy整数是固定宽度的,就像C一样。NumPy好像给了你底层C编译器的左移行为(这可能是底层机器的左移行为),而不是引发错误。 – user2357112