What is Byte Ordering?
Different machine has different architecture, it stores byte in different order, either in “Big-Endian” or in “Little-Endian”.
Big-Endian – The most significant byte is on the left end of a word.
Little-Endian – The most significant byte is on the right end of a word.
For string: E.g. “YOU”
Big Endian | ||||
---|---|---|---|---|
Address | 1000 | 1001 | 1002 | 1003 |
Value | ‘Y’ | ‘O’ | ‘U’ | ‘\0’ |
Little Endian | ||||
---|---|---|---|---|
Address | 1000 | 1001 | 1002 | 1003 |
Value | ‘\0’ | ‘O’ | ‘U’ | ‘Y’ |
For Hex value: E.g.12345678
Big Endian | ||||
---|---|---|---|---|
Address | 1000 | 1001 | 1002 | 1003 |
Value | 12 | 34 | 56 | 78 |
Binary Value | 0001 0010 | 0011 0100 | 0101 0110 | 0111 1000 |
Little Endian | ||||
---|---|---|---|---|
Address | 1000 | 1001 | 1002 | 1003 |
Value | 78 | 56 | 34 | 12 |
Binary Value | 0111 1000 | 0101 0110 | 0011 0100 | 0001 0010 |