Hey Rustaceans! Got an easy question? Ask here (11/2022)!

Hey guys, I'm using the bincode crate to serialize data and according to the docs unsigned integers are represented with a 1-byte flag which specifies the encoding length and is followed by the corresponding integer. The issue I'm having is that I'm trying to encode, for example, the u64 14217254977967302745, which converted to hex is 0xc54dd61382e52859, but when serialized and encoded to hex is 0xfd5928e58213d64dc5 (where fd is the flag indicating a u64). Why is the serialized integer in this case not 0xfdc54dd61382e52859? Curiously, if I serialize 0xd5928e58213d64dc5 (the bincode representation of my first number excluding the 'fd' flag) the result is 0xfdc54dd61382e52859 (where 0xc54dd61382e52859 is the hex of the number I originally tried to serialize).

I hope I explained that well enough. Any help would be greatly appreciated, there doesn't seem to be more information on this in the bincode docs.

/r/rust Thread