echo '' ;

Embedded – Little Endian and Big Endian

“Little Endian and Big Endian” are two different ways of storing multi-byte data types like integers, floating-point numbers, etc., in computer memory.

The architecture of the processor determines the choice between these two types. Little type is commonly used in x86 and x86-64 architectures, while Big type may be used in some older architectures and network protocols. The endianness of a system can affect data interchange between systems with different endianness.

  • Little and big are two ways of storing multibyte data types ( int, float, etc).

To illustrate this, let’s consider a 4-byte integer 0x12345678:

Big Type

In this type of system, the lowest memory address stores the most significant byte (referred to as the “big end”) of a multi-byte data type, while subsequent bytes store in decreasing order of significance. That is, the most significant byte comes first.

In this type, it would be stored as 12 34 56 78 in memory, with the most significant byte 12 stored at the lowest memory address.

Little Type

In a Little type system, multi-byte data types store the least significant byte (referred to as the “little end”) at the lowest memory address, with subsequent bytes arranged in increasing order of significance. That is, the least significant byte comes first.

In Little Type, it would be stored as 78 56 34 12 in memory, with the least significant byte 78 stored at the lowest memory address.

Example-1: Understanding of Little Endian and Big Endian

Lets assume the value 0x01234567 (4Byte Data) will be going to store in Memory.

The below Image Link

Example-2: Understanding

Lets assume the value 0xFFAA5500 (4Byte Data) will be going to store in address from 4000 to 40003.

Little Type

AddressData
4003FF
4002AA
400155
400000

Big Type

AddressData
400300
400255
4001AA
4000FF

Example-3: Understanding

Let’s assume the value 0x6573A429 (4Byte Data) will be going to store in a 32-bit machine address from 20008 to 20000B.

AddressLittle TypeBig Endian Type
200086565
200097373
2000AA4A4
2000B6529

C Example Code

Advantage and Disadvantage

Certainly! Here’s a table summarizing the advantages and disadvantages of Little Type and Big Type:

AspectLittle EndianBig Endian
Advantages
EfficiencyEfficient memory access due to direct access to least significant byteHuman-readable representation aligning with natural digit order
Conversion EaseSimplified byte swapping operations for data interchangeConsistency with some network protocols and file formats
Compatibility
Disadvantages
CompatibilityPotential compatibility issues when interacting with Big Endian systemsByte swapping overhead for data interchange with Little Endian systems
Memory AccessLess efficient memory access due to potential byte swapping

NEXT

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.