InterviewDB Question

Processor Endianness: Detect and Convert Between Little-Endian and Big-Endian Byte Orders

Question Details

Problem Write a function in C that detects at runtime whether the current processor is little-endian or big-endian, and implement functions to swap the byte order of 16-bit, 32-bit, and 64-bit integers. Example: Follow-ups Describe the union-based trick for detecting endianness at runtime without undefined behavior. Why does network protocol code (sockets) always use htonl/ntohl, and what standard defines this? How do modern compilers (GCC, Clang) optimize bswap32 -- what intrinsic or instructio…

Full Details

🔒

Unlock all Anduril questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a anduril interview during the phone round.

It covers the following topics: Coding, Embedded, Phone .