Little Endian vs Big Endian

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).

  little_big_endian

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 :

Screenshot from 2018-06-17 16:59:40

  • Now, checking Endianness of system also :

Screenshot from 2018-06-17 17:04:22.png

LittleBigEndiab

Simple C code to check endianness of given system in simple way 

Example :-

Screenshot from 2018-06-17 17:24:58.png

To simplify above code :-

Screenshot from 2018-06-17 17:31:30

Some other ways to find out the Endianness :-

Screenshot from 2018-06-17 17:40:47.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s