Little Endian and Big Endian are two methods of storing multi-byte data in computer memory. Little Endian stores the least significant byte first, while Big Endian stores the most significant byte first. Understanding endianness is essential in embedded C, microcontrollers, ARM architecture, and data communication.
When working with microcontrollers, processors, and embedded systems, understanding how data is stored in memory is important. A processor handles data in binary format, but the way multi-byte data is arranged in memory can differ depending on the system architecture. This concept is known as endianness. It determines the order in which individual bytes of a data value are stored in computer memory. There are two main types of byte ordering: Little Endian and Big Endian. Understanding the little endian and big endian difference is useful for embedded C programming, microcontroller development, memory organization, and communication between different hardware platforms In this guide, we will explore what endianness means, how it works, its practical examples, and why it matters in embedded systems.
Endianness in computer architecture refers to the order in which bytes of a multi-byte data value are stored in memory.
A processor may handle 16-bit, 32-bit or 64-bit data. Since computer memory is byte-addressable in many architectures, these values occupy multiple consecutive memory locations. Endianness determines which byte is placed at the lowest memory address.
There are two common types:
Both methods represent the same numerical value. The difference is only in how its bytes are arranged in memory.
Little Endian byte order stores the least significant byte first, meaning the byte with the lowest numerical significance is placed at the lowest memory address.
Consider the following 32-bit hexadecimal value:
0x12345678
This value contains four bytes: 12 34 56 78. In Little Endian format, the bytes are stored in reverse order:
| Memory Address | Stored Byte |
| 0x1000 | 0x78 |
| 0x1001 | 0x56 |
| 0x1002 | 0x34 |
| 0x1003 | 0x12 |
Here, 0x78 is the least significant byte, so it is stored first.
Big Endian byte order stores the most significant byte first. The byte with the highest numerical significance is placed at the lowest memory address.
Using the same 32-bit value, 0x12345678, the bytes are stored in their original order:
| Memory Address | Stored Byte |
| 0x1000 | 0x12 |
| 0x1001 | 0x34 |
| 0x1002 | 0x56 |
| 0x1003 | 0x78 |
Here, 0x12 is the most significant byte, so it is stored first.
The little endian and big endian difference mainly relates to how bytes are arranged in memory.
| Feature | Little Endian | Big Endian |
| Byte order | Least significant byte first | Most significant byte first |
| Lowest memory address | LSB | MSB |
| Memory arrangement | Reverse byte order | Original byte order |
| Example | 78 56 34 12 | 12 34 56 78 |
| Common example | x86 processors | Network byte order |
| Usage | Many embedded platforms | Network protocols and some processors |
Both formats store the same numerical value. Neither format is inherently better for every application.
To understand how endianness works, consider a 16-bit value, 0x1234. This value contains two bytes:
In Little Endian memory layout:
| Address | Byte |
| 0x2000 | 0x34 |
| 0x2001 | 0x12 |
In Big Endian memory layout:
| Address | Byte |
| 0x2000 | 0x12 |
| 0x2001 | 0x34 |
The processor uses its architecture and configuration to interpret these bytes correctly when reading the complete value.
It is important to understand that endianness affects the arrangement of bytes, not the order of bits within an individual byte.
In C programming, endianness becomes important when working with pointers, memory addresses, unions, binary files and hardware registers. If you are new to pointers and memory, start with C programming and then move to Embedded C.
Consider this example:
#include <stdio.h>
#include <stdint.h>
int main()
{
uint32_t num = 0x12345678;
uint8_t *ptr = (uint8_t *)#
printf("First byte: 0x%02X\n", ptr[0]);
printf("Second byte: 0x%02X\n", ptr[1]);
printf("Third byte: 0x%02X\n", ptr[2]);
printf("Fourth byte: 0x%02X\n", ptr[3]);
return 0;
}First byte: 0x78 Second byte: 0x56 Third byte: 0x34 Fourth byte: 0x12
First byte: 0x12 Second byte: 0x34 Third byte: 0x56 Fourth byte: 0x78
This example demonstrates how the same C variable can have a different byte arrangement depending on the system’s endianness.
Developers can use a simple C program to identify whether a system uses Little Endian or Big Endian byte ordering.
#include <stdio.h>
#include <stdint.h>
int main()
{
uint32_t num = 1;
uint8_t *ptr = (uint8_t *)#
if (ptr[0] == 1)
{
printf("Little Endian System\n");
}
else
{
printf("Big Endian System\n");
}
return 0;
}Explanation:
This technique assumes the system uses conventional byte-addressable storage and the expected integer representation.
Endianness in embedded systems is particularly important because embedded devices frequently communicate with sensors, processors, communication modules and other hardware components.
A microcontroller may receive data from an external device in a particular byte order. If the receiving processor interprets those bytes incorrectly, the resulting numerical value may be incorrect.
For example, suppose a sensor sends the following two bytes: 0x12 0x34
If the data represents a 16-bit big-endian value, the correct result is 0x1234. If a little-endian processor directly interprets the same byte sequence as a native 16-bit value, it may interpret it as 0x3412.
Therefore, developers must understand byte ordering when implementing communication protocols and processing received data.
When two microcontrollers exchange multi-byte data, both systems must agree on the byte order.
UART transmits data as a sequence of bytes. Developers must define how multiple bytes represent a larger numerical value.
SPI transfers data in a configured bit sequence. The application must correctly interpret the bytes received from the connected device.
I2C devices may transmit 16-bit or 32-bit register values using a specified byte order. Firmware developers must follow the device datasheet. You can read more about these in our guide to microcontroller communication protocols.
Automotive ECUs exchange data using communication protocols such as CAN. Understanding byte ordering is essential when decoding multi-byte signals.
ARM architecture supports different memory byte-order configurations, depending on the processor implementation and system configuration.
Many commonly used ARM Cortex-M microcontrollers operate in Little Endian mode. STM32 microcontrollers based on ARM Cortex-M processors commonly use Little Endian memory representation.
For example, when an STM32 program stores the 32-bit value 0x12345678, its byte representation in memory is typically: 78 56 34 12
This knowledge is useful when:
Always refer to the specific processor and microcontroller documentation when checking supported byte-order configurations.
Endianness conversion means changing the byte order of a multi-byte value from one format to another.
For example:
A simple function for converting a 32-bit value is:
#include <stdint.h>
uint32_t swap_endian(uint32_t value)
{
return ((value >> 24) & 0x000000FF) |
((value >> 8) & 0x0000FF00) |
((value << 8) & 0x00FF0000) |
((value << 24) & 0xFF000000);
}This function reverses the four bytes of a 32-bit value. Endianness conversion is useful when exchanging data between systems that use different byte orders.
In production firmware, developers should also consider the protocol’s specified byte order and use safe byte-wise serialisation and deserialisation methods.
Neither byte-order format is universally superior. Each has characteristics that make it suitable for different systems and applications.
Little Endian and Big Endian are two different ways of arranging multi-byte data in computer memory. Little Endian stores the least significant byte first, while Big Endian stores the most significant byte first.
Understanding byte order in computer architecture is essential for embedded developers working with microcontrollers, ARM processors, Embedded C programming, communication protocols and memory operations.
Whether you are developing firmware for STM32, working with UART and SPI communication or debugging microcontroller memory, understanding endianness helps prevent data interpretation errors and improves your ability to develop reliable embedded applications. To practise these concepts with hands-on training, explore the Embedded Systems Course with Placement at IIES.
Little Endian stores the least significant byte at the lowest memory address, whereas Big Endian stores the most significant byte at the lowest memory address.
You can use a C program with a pointer to inspect the first byte of a multi-byte integer.
ARM architecture supports different byte-order configurations. Most commonly used ARM Cortex-M microcontrollers operate in Little Endian mode.
It helps developers correctly interpret multi-byte data exchanged between microcontrollers, sensors, communication interfaces, and processors.
Network byte order is Big Endian, meaning the most significant byte is transmitted first for multi-byte protocol fields.
Indian Institute of Embedded Systems – IIES