繁体   English   中英

Python - 为什么 CRC32(np.int64(1)) 的结果与 CRC32(np.int32(1)) 不同?

[英]Python - Why is result of CRC32(np.int64(1)) different to CRC32(np.int32(1))?

Python 中的 CRC32 比较:

>>> zlib.crc32(np.int64(1)) == zlib.crc32(np.int32(1))
False

>>> np.int64(1) == np.int32(1)
True

>>> zlib.crc32(np.int64(1))
2844319735

>>> zlib.crc32(np.int32(1))
2583214201

1 的多项式表达式,无论是 int64 还是 int32 数据类型,都应该相同,但它们的 CRC32 结果不同。 我尝试了许多其他数字而不是 1 并且 int64 和 int32 结果的 CRC32 仍然不匹配。

任何帮助解决这个令人难以置信的混乱问题的帮助将不胜感激。

cbc32 处理字节。

int32 是 4 个字节, 101 00 00 00

int64 是 8 个字节, 101 00 00 00 00 00 00 00

>>> zlib.crc32(np.int64(1)) == zlib.crc32(b''.join([np.int32(1), np.int32(0)]))
True

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM