Closed bahollis closed 13 years ago
You are correct. I could easily have done two's complement. I will correct that in the next release.... which will hopefully be later this week.
As for why I chose the scheme that I did... I was thinking.... I know exactly what (ldb ...) will return on the high bytes of (+ x offset) and I don't know what it will return on the high bytes of (- x) for things larger than a fixnum.
That said... I should have realized that I knew exactly the number of bits involved and could easily have done the "flip-the-bits-and-add-one" thing.
I look forward to the next release ^^
Completed the fix in github. Tarball release coming very soon.
This project is looking very nice, but I have 1 small criticism. That being the rather non-standard standard signed integer serializers. I cannot come up with a good reason for why you chose the scheme of 2's compliment AND an explicit sign bit.
This rules out communicating with any other client/server that does not implement this rare scheme. Forcing the end user to define a proper serializer for straight up 2's compliment integers. I think it would be a better idea to implement the standard signed integer serializer as just 2's compliment, as this is the representation used by the vast majority of network protocols.
I have modified the make-int-serializer macro to implement standard 2's compliment. I am sure there is a more optimal way of doing it, but this is what I could do in the 10 minutes I was willing to devote to it ^^