Endianness refers to the sequential order in which bytes are arranged into larger numerical values when stored in memory.
Simple way to remember is “little endian, the least significant byte will go to lowest address index. and Vice versa.
Little endian and big endian are two ways of storing multi byte/nibble data-types ( i.e. int, float, etc).
in big endian machines,
first byte of binary representation of the multi
byte data-type is stored first.
On the other hand, In little endian machines,
last byte of binary representation of the multi
byte data-type is stored first.
Current architectures
The Intel x86 and also AMD64 / x86-64 series of processors use the little-endian format, and for this reason, it is also known in the industry as the “Intel convention“.
Some current big-endian architectures include the IBM z/architecture, Freescale ColdFire (which is Motorola 68000 series-based), Xilinx MicroBlaze, Atmel AVR-32.
As a consequence of its original implementation on the Intel 8080 platform, the operating system-independent FAT file system is defined to use little-endian byte ordering, even on platforms using other endiannesses natively.
Big-endian is the most common format in data networking, fields in the protocols of the Internet protocol suite, such as IPv4, IPv6, TCP, and UDP, are transmitted in big-endian order. For this reason, big-endian byte order is also referred to as network byte order.
Little-endian storage is popular for microprocessors, in part due to significant influence on microprocessor designs by Intel Corporation.
Example :-
Suppose integer is stored as 4 bytes then a variable var with value 0x01234567 will be stored as following.
C code to see your system memory presentation as well as Endianness :-
Source Code :-
- checking memory representation :
- Now, checking Endianness of system also :
Simple C code to check endianness of given system in simple way
Example :-
To simplify above code :-
Some other ways to find out the Endianness :-