Re:MessagePack: like JSON, but fast and small
by kingofpandora on Tuesday March 10, 2020 @02:32PM
(#22538116)
Genuine question - is it dangerous to memcpy X bytes that we know must be interpreted as, say, an integer?
[ Parent
| on HN ]
Re:MessagePack: like JSON, but fast and small
by byte1918 on Tuesday March 10, 2020 @03:10PM
(#22538522)
No. Everything is 0s and 1s after all. Take for eg. a byte. It has 8 bits and by permutating all the 0s and 1s you end up with all the possible values of a signed byte; all the numbers -128 to 127. So now, if you were to copy a byte from a random memory location that byte will just contain a permutation of 0s and 1s which when interpreted as a signed int, will simply contain a number between -128 and 127.
Re:MessagePack: like JSON, but fast and small
by kingofpandora on Tuesday March 10, 2020 @04:02PM
(#22539060)
That's what I thought ...
Re:MessagePack: like JSON, but fast and small
by tangent128 on Tuesday March 10, 2020 @03:01PM
(#22538451)
Potentially. Most network protocols are big-endian while x86 is little-endian.