Skip to content
RED SAGSkills
easyEmbedded Systems Engineer interview question

What is endianness, and how do you deal with it when exchanging data between devices?

What the interviewer wants to hear

  • Order in which bytes of a multi-byte value are stored
  • Little-endian stores least significant byte first; big-endian most significant first
  • Most MCUs are little-endian; network byte order is big-endian
  • Define the byte order in the protocol and convert explicitly with shifts
  • Avoid sending raw structs because of padding and byte order

Model answer

Endianness is the order in which a multi-byte value is stored in memory. Little-endian puts the least significant byte at the lowest address, and big-endian puts the most significant byte first. Most Cortex-M and RISC-V MCUs are little-endian, while many network protocols and some sensors use big-endian, often called network byte order. When devices exchange data, I make the byte order part of the protocol specification and convert explicitly, building values with shifts, such as (b[0] << 8) | b[1], instead of casting a byte pointer to a wider type. That code works on any CPU and also avoids alignment problems. I avoid sending raw C structs because padding and byte order differ between compilers and processors, and I write unit tests with known byte sequences.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Embedded Systems Engineer questions