mradziwo / MsgPack_LabVIEW

It's like JSON, but fast and small…and LabVIEW! – msgpack.org[LabVIEW]
http://msgpack.org
MIT License
2 stars 4 forks source link

decoding of positive fixint mixed with int #3

Closed zoyo-de closed 6 years ago

zoyo-de commented 6 years ago

Hi, I just see that decodeObject.vi calls for values of 0..127 decodeInt.vi. This has a case for these values, which are positive fixint, but convert it to i8. I would expect that decodeObject.vi should call decodeUInt.vi which implements this case and converts it to the correct u8. Maybe I missed something but this looks odd.

kind regards, Christian

mradziwo commented 6 years ago

I have copied this behavior from one of the C implementations. It treats any value from -128 to 127 as i8. I agree it may seem counter intuitive to convert 0-127 to i8, but on the other hand it's consistent with -128-0 range and in case of LabVIEW implementation has no impact if one would like to cast 0-127 as u8.

zoyo-de commented 6 years ago

Yes, it's just an unexpected type conversion.

mradziwo commented 6 years ago

I got convinced by this convention - though I'm far from being dogmatic about it. Code implementation guide says only that string should be decoded to smallest possible type - and for me u8 and i8 are the same size.

Btw - what are you using MsgPack for? Should we throw this conversation to private? Reach me at mradziwo@gmail.com.