CSArchitecture & RuntimeDiagramIntermediate
Endianness
KO: 엔디안 (Endianness)·EN: Endianness·JA: エンディアン(バイトオーダー)
The byte ordering convention defining whether the most-significant byte (Big-Endian) or least-significant byte (Little-Endian) sits at the lowest memory address
Table of Contents
Structure Diagram
Big-Endian vs Little-Endian Byte Order (0x12345678)
BIGBig-Endian
Most Significant Byte first · Network byte order
- Memory Layout[0]: 12 | [1]: 34 | [2]: 56 | [3]: 78
- ReadabilityMatches human left-to-right hex dumps
- StandardsTCP/IP headers, PNG, JPEG, JVM bytecode
LITTLELittle-Endian
Least Significant Byte first · Modern CPU standard
- Memory Layout[0]: 78 | [1]: 56 | [2]: 34 | [3]: 12
- Hardware BenefitSame base address when casting 32-bit to 8-bit
- Architecturesx86-64, ARM64 (Apple Silicon), WebAssembly
Quick Answer
What is Endianness?
The byte ordering convention defining whether the most-significant byte (Big-Endian) or least-significant byte (Little-Endian) sits at the lowest memory address. It is a core concept in Architecture & Runtime within CS.
Core Principles
Endianness (Byte Order) defines how multi-byte integers like 0x12345678 are arranged across byte-addressed memory or wire streams.
- Big-Endian: Stores the Most Significant Byte (
0x12) at the lowest address—standard for Network Byte Order (TCP/IP). - Little-Endian: Stores the Least Significant Byte (
0x78) first—standard on virtually all modern CPUs (x86-64, ARM64).
Practical Takeaways
- Always specify endianness in binary I/O: Use
htonl/ntohl, Go'sencoding/binary, or JSDataViewendian flags explicitly instead of relying on host byte order. - UTF-8 avoids endianness: Byte-oriented UTF-8 needs no byte-order mark, whereas UTF-16/UTF-32 require LE/BE specification.
- Never dump raw structs over the wire: Use portable formats like Protobuf, MessagePack, or FlatBuffers to handle both endianness and struct padding.
Notable Examples
- Network Protocols (IP, TCP, UDP, PNG): Big-Endian wire format.
- x86-64, ARM64, WebAssembly: Little-Endian native execution.