Endianness
In this article we will talk about the concept of
endianness,how it works and what are the types of endianness exist.
It is a very important and unfamiliar topic when we talk
about transmission or converting the data.
In speaking of general terms, Endianness in C or just
endianness refers to the bytes order in which data is stored in the memory and
also describes the order of byte transmission over a digital link.
Depending on the endianness and system used, It exist in 2
types.
1.) Big endian
2.) little
endian
If your machine is big-endian then the MSB byte store first
(means at lower address) and if the machine is the little-endian then LSB byte
store first (means at lower address)
Now let us understand how little endian and big endian
machines stores the data one by one with the help of an example.
We are storing a value 0x11223344( Taking a value in
hexadecimal code for better understanding).
Big-endian
As we know that in big-endian MSB Byte will store first. It
means the MSB Byte will store at the lowest memory address.
It means the numbers starting from the left will store first
like in example 0x11223344, 11 will be stored in the memory first then 22 and
so on.
Little-endian
In the little endian machine, LSB byte will store first. So
the LSB Byte will store at the lowest memory address
In little endian,the least significant byte will store first, that means 44 will store at the address and then 33 till 11.
Conclusion
We find there is no advantage of using one endianness over
the other, both only define the byte sequence order. Today mostly personal
computers and desktop come in little-endian architecture. Endian also do not
affect the single-byte it only affects the multi-byte data because we consider
byte is the atomic unit from the storage point of view.
Note:-
MSB - Most significant
byte
LSB - Least significant byte
No comments:
Post a Comment