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

537 Views Asked by At

CRC32 comparisons in Python:

>>> 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

The polynomial expression of 1, regardless of its int64 or int32 data type, should be the same and yet their CRC32 results are different. I've tried many other numbers than 1 and the CRC32 of the int64 and int32 results still won't match.

Any help in clearing up this incredibly confusing issue would be very much appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

cbc32 works on bytes.

int32 is 4 bytes, 1 is 01 00 00 00

int64 is 8 bytes, 1 is 01 00 00 00 00 00 00 00

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