Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 696 Bytes

File metadata and controls

25 lines (20 loc) · 696 Bytes

ENDIANESS

Source

This how the bytes are ordered in memory.
Very important especially when dealing with sockets.
Crux of it - Check the starting address.

  • BIG - Most Significant BYTE (MSB)
  • LITTLE - Less Significant BYTE (LSB)
// Consider a 4 byte integer.
int32_t a = 0xABCDEFGH;

// Big Endian
start address -> AB CD EF GH

// Little Endian
start address -> GH EF CD AB

Code to check for endianess

Considerations:

  • Machines mostly little endian. Helps expansion typecasting.
  • Network Byte Order (Socket Comms) is big endian.
  • Typecasting scenarios where the size of datatype changes.