Closed reynir closed 1 year ago
Then I dug into the checkseum tests and discovered they were using Optint.unsigned_of_int32.
Yes, the bit sign matters along cast for the optint
point-of-view. And indeed, we probably should add {of,to}_int32
as you said.
I am using
Checkseum.Crc32
, and I serialized usingOptint.to_int32
and deserialized usingOptint.of_int32
, and my code didn't work. First I usedOptint.pp
to print the two checksums and indeed they were different:Then later I switched to using
Printf.printf "Back checksum: %ld vs %ld" (Optint.to_int32 crc) (Optint.to_int32 crc')
: and gotBad CRC -1407441036 vs -1407441036
which is confusing. Then I dug into the checkseum tests and discovered they were usingOptint.unsigned_of_int32
.I suggest perhaps
Checkseum.S.{of,to}_int32
to the interface so others don't make the same mistake.