I see this in protocols and other situations, where data is packed in a way so no matter what the value of a number is, it occupies the same space, for easy reading.
ex:
Say a protocol starts with a header saying the packet size, it will send something like:
0x0 0x0 0x3
The receiver knows to read 3 bytes, then turn that value into an int, and that's the size. In this case 3.
0x0 0x1 0x4
would be 20, for example
now I've also seen some do this:
0x4 0x1 0x0.
Basically, they reverse the bytes, so when you read it, you have to oreorder them before you can get the value. This slows down the program when this has to be done very often. Is there any given reason some protocols do this?
ex:
Say a protocol starts with a header saying the packet size, it will send something like:
0x0 0x0 0x3
The receiver knows to read 3 bytes, then turn that value into an int, and that's the size. In this case 3.
0x0 0x1 0x4
would be 20, for example
now I've also seen some do this:
0x4 0x1 0x0.
Basically, they reverse the bytes, so when you read it, you have to oreorder them before you can get the value. This slows down the program when this has to be done very often. Is there any given reason some protocols do this?
