For programs objects that span multiple bytes it’s necessary to establish two conventions:
In virtually all machines this object is stored as a contiguous sequence of bytes, where the address is the smallest address of the byte used. This can be checked with this C code:
It prints:
Visual representation (of another number):
Some machines use a different order:
This byte ordering is totally irrelevant, one is not better than the other. Little endian is used almost everywhere. For application programmers the order is totally invisible, compilers will deal with that stuff. However, ordering matters when sending sending binary data over the network. A common problem is for data to be sent by a little endian machine to be read by a big endian, or vice versa. This leads to problem. Code written for networking applications must follow established conventions for byte ordering to make sure the sending machine converts its internal representation to the network standard, while the receiving machine converts the network standard to its internal representation.
Output: