Little and big endian are method of storing data in machine. Little Endian means that the lower order byte of the number is stored in memory at the lowest address, and the higher order byte is stored at the highest address. That is, the little end comes first. Intel, ARM processor uses little endian.
Little endian memory representation for a 4 byte, 32 bit integer.
Byte3 Byte2 Byte1 Byte0 will be arranged in memory of a variable num with value 0x02458912 as given below:
Base_Address+0 Byte0 – 12
Base_Address+1 Byte1 – 89
Base_Address+2 Byte2 – 45
Base_Address+3 Byte3 – 02
Big Endian means that the higher order byte of the number is stored in memory at the lowest address, and the lower order byte at the highest address. The big end comes first. Motorola processors use big endian.
Big endian memory representation for a 4 byte, 32 bit integer.
Byte3 Byte2 Byte1 Byte0 will be arranged in memory of a variable num with value 0x02458912 as given below:
Base_Address+0 Byte3 – 02
Base_Address+1 Byte2 – 45
Base_Address+2 Byte1 – 89
Base_Address+3 Byte0 – 12
To check a system is little endian or big endian
unsigned int num = 1;
char *chr = (char*)#
if (*chr)
printf(“Little endian”);
else
printf(“Big endian”);
getchar();