Difference between revisions of "Endianness"
(Created page with "Endianness is the term used to describe the byte order of data. Big-endian means data is being sent with the Most Significant Bit (MSB) first. Little-endian means data is...") |
m |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Knowledge Base]] |
||
Endianness is the term used to describe the byte order of data. |
Endianness is the term used to describe the byte order of data. |
||
+ | |||
− | Big-endian means data is being sent with the Most Significant Bit (MSB) first. |
||
− | + | Big-endian means data is being sent or stored with the Most Significant Byte (MSB) first. |
|
+ | Little-endian means data is sent with the Least Significant Byte (LSB) first. |
||
− | Endianness matters, because the CRC changes when the byte is flipped from MSB first to LSB first. |
||
+ | |||
− | Typically, the endianess is determined by the type of data being transferred. |
||
+ | A CPU always has an endianness, even for 8 bit CPUs. |
||
+ | Any CPU stores data in units larger than just single bytes. The stored value can not also be looked at on |
||
+ | a byte-by-[[byte]] basis. If the first byte is the LSB, then the CPU is said to be [[little-endian]]. |
||
+ | If the first byte is the high order byte, it is said to be [[big-endian]]. |
||
+ | |||
+ | Example: |
||
+ | Let's look at a 32-bit CPU, storing the value 0x12345678 in memory: (memory shown in [[hex]]) |
||
+ | Big endian: |
||
+ | 12 34 56 78 |
||
+ | |||
+ | Little endian: |
||
+ | 78 56 34 12 |
||
+ | |||
+ | For most CPUs, the endianness is fixed by design. For those CPUs, Little-endian is more popular. |
||
+ | All x86 CPUs use little endian. On ARM processors, the endianness is selectable by the chip designer, |
||
+ | but in reality again a vast majority of CPUs is little endian, making it the de-facto standard. |
||
+ | Motorola processors such as Power-PC are big-endian. |
||
+ | ==Internet== |
||
+ | In the internet, the byte order is big-endian. This means that little endian processors are a slight |
||
+ | disadvantagem as they need to swap endianness each time they write to a packet to be send or read from a received packet and kind of protocol information. |
Latest revision as of 16:10, 7 July 2019
Endianness is the term used to describe the byte order of data.
Big-endian means data is being sent or stored with the Most Significant Byte (MSB) first. Little-endian means data is sent with the Least Significant Byte (LSB) first.
A CPU always has an endianness, even for 8 bit CPUs. Any CPU stores data in units larger than just single bytes. The stored value can not also be looked at on a byte-by-byte basis. If the first byte is the LSB, then the CPU is said to be little-endian. If the first byte is the high order byte, it is said to be big-endian.
Example: Let's look at a 32-bit CPU, storing the value 0x12345678 in memory: (memory shown in hex) Big endian: 12 34 56 78
Little endian: 78 56 34 12
For most CPUs, the endianness is fixed by design. For those CPUs, Little-endian is more popular. All x86 CPUs use little endian. On ARM processors, the endianness is selectable by the chip designer, but in reality again a vast majority of CPUs is little endian, making it the de-facto standard. Motorola processors such as Power-PC are big-endian.
Internet
In the internet, the byte order is big-endian. This means that little endian processors are a slight disadvantagem as they need to swap endianness each time they write to a packet to be send or read from a received packet and kind of protocol information.