Closed kleinweby closed 1 year ago
I've added an additional commit to make clippy happy with the current master.
Hi, sorry for the long delay ... I can confirm the problem and will merge the commit after some additional tests. Thanks
Merged in 22ebd425eec29477e12776c4edf9693b12e549da Thanks!
When encoding unsigned integers we must prefix the representation with an extra 0x00 if the high bit is set. Otherwise it would be interpreted as a negative number.
Additionally we should remove any redundant leading 0xFF and 0x00 bytes.
Before this patch the code would mixed up these encodings. It would always add an 0x00 to signed negative numbers and remove leading 0x00 for positive numbers.
This patch introduces encode tests akin to the decode tests for integers and fixes the implementations for encoding.
Additionally we fixed to tests that tested for this wrong behaviour.