endianness
  • in computer systems endianness is the order by which a computer arranges bytes in memory , similar to how different languages read from different sides .The concept of endianness is crucial in understanding how these bytes are read and interpreted by computers,since a computer is already fine with the files in it , issues with endianness rather arise when two computer want to communicate.

  • Endianness comes in two primary forms: Big-endian (BE) and Little-endian (LE).

  • Big-endian (BE): Stores the most significant byte (the “big end”) first. This means that the first byte (at the lowest memory address) is the largest, which makes the most sense to people who read left to right.

  • Little-endian (LE): Stores the least significant byte (the “little end”) first. This means that the first byte (at the lowest memory address) is the smallest, which makes the most sense to people who read right to left.

  • in Big endian , the most significant byte (MSB) is stored in the lowest address in memory , meaning that it has the smallest address , for example , in a Big endian system the integer 0x12345678 will be stored is follows:
    Pasted image 20240904183447.png

  • the little endian system uses the same terminology , however , it is inversed , the least significant byte (LSB) is the the one stored in the smallest address, in little endian systems , the integer 0x12345678 will be stored like this :
    Pasted image 20240904183800.png

  • But what do we mean by the significance of a byte?

    • in a number the order of a digit is simply the value of it in the number according to the numbering system, in the decimal system the number 1234 is fundamentaly this :

      as we see 1 is multiplied by the 10 of the highest order and thus has the highest value .
    • same can be applied in hex and of course in binary , that's it.

When Might Endianness Be an Issue?

Endianness must be considered in various computing scenarios, particularly when systems with different byte orders need to communicate or share data.

  1. **Unicode Characters:** Unicode, the character set used universally across devices, uses a special character byte sequence called the Byte Order Mark (BOM).] The **BOM**** informs the system that the incoming stream is Unicode, specifies which Unicode character encoding is used, and indicates the endian order of the incoming stream.
  2. Programming Languages: Some programming languages require specifying the byte order sequence. For instance, in **Swift**, used for **iOS** development, you can define whether data is stored in **big-endian** or **little-endian format**.
  3. **Network Protocols:** Different protocols have emerged historically, leading to the need for interaction. **Big-endian** is the dominant order in network protocols and is referred to as network order. Conversely, most PCs use **little-endian** format. Ensuring interoperability between these formats is critical in network communication.
  4. **Processor Design:** Processors can be designed to be either **little-endian, big-endian,** or **bi-endian** (capable of handling both). Consumer choice and the resulting market trends have influenced what is considered “normal” in computer systems today.

Why is Endianness an Issue?

**Endianness** becomes an issue primarily due to the interaction between different systems and protocols. Historical protocol development led to varying byte order conventions, necessitating data conversion for compatibility. In higher-level languages and abstracted environments, endianness is often managed behind the scenes, reducing the need for developer concern. However, understanding endianness remains crucial for low-level programming, network protocol design, and data interoperability.