Processor byte ordering simplified
Q) What is byte ordering?
Ans) Its the processor architecture to decide in which order bytes will be laid in the memory address.
Q) Types of byte ordering?
Ans) Two. big-endian and little-endian
Q) What is big-endian byte ordering?
Ans) In big-endian byte order, the highest byte address occurs in the least significant byte(LSB). For e.g: in 32 bit integer with value : 0x05765401
Byte Address 0x01 | 0x02 | 0x03 | 0x04 | Byte Data 0x05 | 0x76 | 0x54 | 0x01 |
Q) What is little-endian byte ordering?
Ans) In little-endian byte order, the highest byte address occurs in the most significant byte(MSB). Considering same integer value 0x05765401
Byte Address 0x01 | 0x02 | 0x03 | 0x04 | Byte Data 0x01 | 0x54 | 0x76 | 0x05 |
Note: Regardless of the processor byte ordering, most significant byte is always on the left, and the least significant byte is always on the right. Means 0x05 is always MSB and 0x01 is always LSB .
Verification: cast a char pointer to the address of the integer.
unsigned int i = 0x05765401
char * p = (char*)&i;
check the value at p[0]
In machines having big-endian processor architecture, p[0] will be 5 i.e the most significant byte.
In machines having little-endian processor architecture , p[0] will be 1 i.e the least significant byte.
References: Advance Programming in the UNIX Environment (W. Richard Stevens, Stephen A. Rago)














