Memory is a row of numbered bytes, and most numbers a program handles are wider than one byte: a port is two bytes, an IPv4 address four, a 64-bit counter eight. Such a number has to be spread over consecutive addresses, and there are two ways to do it. Put the most significant byte at the lowest address and the machine is ; put the least significant byte there and it is little-endian. Nothing else changes, and that is the trouble: the same four bytes are two different numbers, depending on which convention reads them.

In short: big-endian stores the high byte first and is the order of Internet protocol headers; little-endian stores the low byte first and is the order of and of most systems. A program that moves numbers between the two converts at the boundary (htonl, ntohs, 's struct with !), and a program that forgets gets a different number and no error.

Two ways to lay out one number

states both definitions in one place. "A little-endian representation of an integer has the least significant byte stored as the first byte, with the significance of the bytes increasing as the byte address increases. A big-endian representation has the most significant byte as the first byte" (The Open Group, be16toh).

Take the 32-bit value 0x0A0B0C0D (168 496 141 in decimal) and store it at address 0x1000:

AddressBig-endianLittle-endian
0x10000A0D
0x10010B0C
0x10020C0B
0x10030D0A

Big-endian reads like the number written on paper; little-endian puts the "units" byte first, so the significance of each byte grows with its address. Both are complete and self-consistent, and a machine of either kind reads its own data back correctly. The difficulty only starts when the bytes leave: in a file, in a packet, or in memory shared with a device that uses the other convention. Python shows the two layouts directly:

# The same 32-bit value packed little-endian, big-endian, and in the host's own order.
import struct, sys
v = 0x0A0B0C0D
print(struct.pack("<I", v).hex(" "))   # little-endian
print(struct.pack(">I", v).hex(" "))   # big-endian
print(struct.pack("=I", v).hex(" "), sys.byteorder)  # native order, and its name
0d 0c 0b 0a
0a 0b 0c 0d
0d 0c 0b 0a little

That run was on 3.13.16 on an x86-64 machine, so the native line matches the little-endian one. 2781 gives the same picture for two bytes: 258 is 0x0102, "the octet 0x01 followed by the octet 0x02" in big-endian and the reverse in little-endian (RFC 2781).

Only the order of bytes within one number changes. A string of single-byte characters is stored in the same order on both, and so is , where the Standard notes "there is no issue of big- versus little-endian byte order" (Unicode 18.0.0, chapter 2). -V puts the same guarantee in its own words: "endianness is byte-address invariant", so a byte stored at an address is the byte read back from it in any order (RISC-V unprivileged ISA).

Where the names come from

The words are older than computers. In Part I, chapter of Jonathan Swift's Gulliver's Travels (1726), Lilliput has been at war with Blefuscu for "six-and-thirty moons" because an emperor commanded "all his subjects, upon great penalties, to break the smaller end of their eggs", and "the books of the Big-endians have been long forbidden" (Project Gutenberg, eBook 829). Swift names only the Big-endians; in that edition the word "Little-endian" does not occur.

supplied the other half. His memo IEN 137 (Internet Experiment Note 137), "On Holy Wars and a Plea for Peace", dated 1 April 1980, opens: "This is an attempt to stop a war." The question, he wrote, is "which bit should travel first, the bit from the little end of the word, or the bit from the big end of the word? The followers of the former approach are called the Little-Endians, and the followers of the latter are called the Big-Endians" (Cohen, IEN 137). RFC 1700 cites the version published in Computer in October 1981 when it pictures data "in 'big-endian' order [COHEN]" (RFC 1700), and the Power ISA (Instruction Set Architecture) that IBM's POWER processors implement, now published by the OpenPOWER Foundation, still prints Swift's whole passage, from the 1734 Dublin edition, in its introduction (Power ISA 3.1C). The story of the memo and its title is told in the glossary entry endianness (On Holy Wars).

Cohen's conclusion is the part worth keeping: "It is more important to agree upon an order than which order is agreed upon." He even noted that Swift's point was the opposite of his own: Swift thought the end of the egg did not matter, so everyone could choose; Cohen agreed it did not matter, "but we insist that everyone must do it in the same way, to avoid anarchy".

Byte order is not bit order

Cohen's memo is mostly about bits. On a serial line the units actually sent are bits, so the real question is which bit of a word goes first. If bits, bytes and words all follow one consistent order, the receiver can group the stream into chunks of any size; if they do not, "the chunk size must be understood and agreed upon by all parties". He also pointed out that inside memory "there is absolutely no specific significance whatsoever to the notion of 'left' and 'right' in bit order": software addresses bytes, never bits. His examples of inconsistency came from the communication world: the (High-Level Data Link Control) protocol sends every field narrow end first, "except the (checksum) field".

The Internet's documents settle bit numbering for the diagrams only: "the bit labeled 0 is the most significant bit", so the octet drawn 1 0 1 0 1 0 1 0 is 170 (RFC 791, Appendix B). The order in which bits travel on a wire is the link layer's business, and there two families of local area networks (LANs) disagreed. RFC 2469 explains 's convention: "The first bit of each byte that appears on the maps to the least significant (i.e., right-most) bit of each byte in memory", which puts the group (multicast) bit "in the least significant bit of the first byte", and "Ethernet and 802.3 hardware behave consistently with this definition". , and some FDDI (Fiber Distributed Data Interface) hardware, mapped the first bit to the most significant one instead, so the canonical address 12-34-56-78-9A-BC sat in such an adapter's memory as 48-2C-6A-1E-59-3D, and bridges between the two kinds of network had to "perform bit swaps of the addresses" inside (Address Resolution Protocol) packets (RFC 2469). That is a bit-order problem; the byte order of the address was the same on both. Least and most significant bit goes further into bit numbering and bit order.

Network byte order

The Internet chose big-endian for its headers, and RFC 791 says so in its Appendix B, "Data Transmission Order": "When a multi-octet quantity is transmitted the most significant octet is transmitted first." RFC 1700, the 1994 Assigned Numbers, generalized it under "Data Notations" for the documentation of all Internet protocols, which "picture data in 'big-endian' order [COHEN]", most significant octet on the left; RFC 1700 itself was made Historic by RFC 3232 in 2002, the assignments having moved to the online registries of , the Internet Assigned Numbers Authority (RFC 3232). The phrase "network byte order" is older than any definition of it: in 2000 RFC 2781 remarked that it "has been used in many RFCs to indicate big-endian serialization, although that term has yet to be formally defined in a standards-track document".

POSIX (the Portable Operating System Interface) defines it. "The convention is that all such values are stored with 8 bits in each octet, and with the first (lowest-addressed) octet holding the most-significant bits. This is called 'network byte order'"; the processor's own layout is "host byte order", and "16 and 32-bit values can be converted using the htonl(), htons(), ntohl(), and ntohs() functions" (POSIX, 4.13 Host and Network Byte Orders). The four functions "convert 16-bit and 32-bit quantities between network byte order and host byte order" (htonl); on a big-endian host they change nothing, on a little-endian host they reverse the bytes. The socket address structure is where they matter: "The sin_port and sin_addr members shall be in network byte order" (netinet/in.h). The 2024 edition of POSIX added <endian.h>, with htobe32(), le32toh() and the rest for 16, 32 and 64 bits in either order, and states the rule in one line: "Network byte order is big-endian" (endian.h, be16toh).

The address 192.0.2.10 travels as the four bytes C0 00 02 0A. Read as one big-endian integer they are 3 221 225 994; loaded into a register by a little-endian processor without conversion, the same bytes are 0x0A0200C0, which is 167 903 424. Both numbers are "the address as an integer", and code that stores one and reads it back as the other has moved the host somewhere else.

Processors: little, big and both

Most processors pick one order; some can run either, which is called bi-endian:

FamilyByte orderDebian ports
x86, x86-64little-endianamd64, i386: little
Armlittle-endian in practice; big-endian data accesses selectablearm64, armel, armhf: little
IBM z/Architecturebig-endians390x: big
IBM Powerbi-endian, chosen by the operating systemppc64el: little; ppc64, powerpc: big
RISC-Vlittle-endian, big-endian or bi-endian variantsriscv64: little
MIPSeither, chosen when the system is builtmipsel, mips64el: little; mips, mips64: big
SPARC V9big-endian, with little-endian data accessessparc64: big

In the documentation's own words, the family's own manual wherever that could be read:

  • x86 and x86-64: Intel 64 and IA-32 processors "are 'little endian' machines; this means the bytes of a word are numbered starting from the least significant byte" (Intel SDM volume 1, section 1.3.1). AMD's manual says the same of both: "The x86 and AMD64 architectures address memory using little-endian byte-ordering. Multibyte values are stored with their least-significant byte at the lowest byte address" (AMD64 APM volume 1, revision 3.25).
  • Arm: the order of data accesses is a bit per exception level in the System Control Register, SCTLR_EL1: EE for "data accesses at EL1" and E0E for "data accesses at EL0", 0 meaning little-endian and 1 big-endian. The bits can be changed only on a processor that implements mixed-endian support (FEAT_MixedEnd); on the others they are fixed, big-endian on a big-endian-only processor and little-endian on the rest (Arm, SCTLR_EL1). Linux's arm64 build asked whoever configured it to "select the endianness of data accesses performed by the CPU", with little-endian as the default, up to version 6.17 (Linux 6.17, arch/arm64/Kconfig).
  • IBM z/Architecture: "a group of bytes in storage is addressed by the leftmost byte of the group", and the leftmost bits are "the 'high-order' bits" (IBM SA22-7832-13, the fourteenth edition of the Principles of Operation, chapter 3).
  • IBM Power: "The byte ordering (Big-Endian or Little-Endian) for a storage access is specified by the operating system" (Power ISA 3.1C, section 1.10).
  • RISC-V: "RISC-V base ISAs have either little-endian or big-endian memory systems, with the privileged architecture further defining bi-endian operation" (RISC-V, intro.adoc).
  • MIPS: "Some MIPS machines can be configured for either little or big endian byte order", in 's configuration (Linux, arch/mips/Kconfig).
  • SPARC V9: "SPARC-V9 uses big-endian byte order by default", and "All instruction accesses are performed using big-endian byte order" (The SPARC Architecture Manual, Version 9).

The last column of the table is Debian's summary of its ports, which also lists loong64 as little-endian and hppa and m68k as big-endian (Debian wiki, ArchitectureSpecificsMemo). Python's struct documentation sums up the practical position: "Intel x86, AMD64 (x86-64), and Apple M1 are little-endian; IBM z and many legacy architectures are big-endian" (Python, struct).

The bi-endian designs differ in what they let change:

  • Power has one switch, the LE mode bit, which "applies to both data accesses and instruction fetches". Debian ships both orders as separate ports, ppc64 and ppc64el.
  • RISC-V never changes its instructions: they "are stored in memory as a sequence of 16-bit little-endian parcels, regardless of memory system endianness". Data order is set per privilege level by the MBE, SBE and UBE bits of mstatus, so that, for instance, "an OS of one endianness" can "execute user-mode programs of the opposite endianness", although the application binary interfaces are not meant to mix: "Standard RISC-V ABIs are expected to be purely little-endian-only or big-endian-only" (RISC-V privileged ISA).
  • SPARC V9 keeps instructions big-endian and lets data be read little-endian "by using selected ASIs", the address space identifiers that tag each access, or by changing the default for user mode, supervisor mode or both, to "support mixed byte order systems".
  • MIPS, in Linux's description, picks one order for the whole system: "These modes require different kernels and a different Linux distribution."
  • Arm's second order is fading in practice. Linux's arm64 big-endian kernel option was marked as depending on BROKEN in 6.18 (Linux 6.18) and is gone from the 7.4 release candidate (Linux 7.4-rc1), while the 32-bit SETEND instruction, which "alters the data-endianness of the AArch32 EL0", is described there as "deprecated in ARMv8".

Swapping bytes: the instructions and the macros

Because the two orders meet at every network interface, processors have instructions for the conversion:

  • x86: BSWAP "reverses the byte order in a 32-bit register operand" and "is useful for converting between 'big-endian' and 'little-endian' data formats"; MOVBE, "Move data after swapping data bytes", does the load or store and the swap in one instruction, and its support is enumerated by a CPUID bit (CPUID.01:ECX.MOVBE, bit 22) (Intel SDM volume 1, as above). AMD documents the same pair: BSWAP "is used to convert data between little-endian and big-endian byte order" and on a 16-bit register its result "is undefined", so a 16-bit swap uses XCHG, and "MOVBE performs a reordering of the bytes within the source operand as it is copied" (AMD64 APM volume 1, as above).
  • Arm: REV, which "reverses the byte order in a register", with REV16 and REV32 doing the same within each 16-bit halfword and each 32-bit word (Arm, A64 instruction set, REV).
  • IBM z: LOAD REVERSED and its relatives "can be used to convert two, four, or eight bytes from a 'little-endian' format to a 'big-endian' format, or vice versa"; IBM's example is that "the bytes ABCD in the big-endian format are DCBA in the little-endian format" (IBM SA22-7832-13, as above).
  • Power: the byte-reverse loads and stores (Load Word Byte-Reverse Indexed and its siblings) and the register forms Byte-Reverse Halfword, Word and Doubleword (Power ISA 3.1C, section 3.3.16).
  • RISC-V: the Zbb extension's rev8, which "reverses the byte-ordering" of a register (RISC-V, zbb.adoc).

How instructions themselves are laid out in memory, little-endian on x86-64, AArch64 and RISC-V, is worked byte by byte in Assembly language and the assembler.

Software rarely writes those by hand. The Linux kernel names every conversion by its direction: cpu_to_be32(), be32_to_cpu(), cpu_to_le16() and so on, defined once per byte order; on a little-endian build cpu_to_le32 is only a type cast and cpu_to_be32 is __swab32, which swab.h maps to the compiler's __builtin_bswap32 where the compiler has one, and otherwise to the architecture's own swap or a portable shift-and-mask version (Linux, include/linux/byteorder/generic.h, little_endian.h, swab.h). Naming the direction rather than "swap" is the useful habit: the same source is right on both kinds of processor, because the macro that does nothing on one does the swap on the other.

Formats and protocols that fix an order

A file or a protocol that is read on more than one kind of machine has to say which order its numbers use, and each has made its choice in its own words:

Format or protocolOrderWhat the specification says
IPv4 and the Internet headersbig-endian"the most significant octet is transmitted first" (RFC 791)
PNG (Portable Network Graphics)big-endian"All integers that require more than one byte shall be in network byte order" (W3C, PNG Third Edition, 7.1)
class filesbig-endian"Multibyte data items are always stored in big-endian order, where the high bytes come first" (Java Virtual Machine Specification, Java SE 25, chapter 4)
(External Data Representation)big-endianan integer's "most and least significant bytes are 0 and 3, respectively" (RFC 4506)
CBOR (Concise Binary Object Representation)big-endian"All multi-byte values are encoded in network byte order (that is, most significant byte first, also known as 'big-endian')" (RFC 8949)
Windows bitmap (BMP)little-endianthe file type field "must be 0x4d42 (the string 'BM')" (Microsoft, BITMAPFILEHEADER): the bytes B (0x42), M (0x4D) make 0x4D42 only when the low byte comes first
WebAssemblylittle-endianmemory "values are read and written in little endian byte order", and floating-point constants are their IEEE 754 bit pattern "in little endian byte order" (WebAssembly 3.0, binary format)
TIFFeither, markedbytes 0 and 1 are "II" for "little-endian byte order" or "MM" for "big-endian byte order"; "TIFF readers must be able to handle both byte orders" (TIFF 6.0)
ELF object fileseither, markede_ident[EI_DATA] is ELFDATA2LSB (1), "the least significant byte occupying the lowest address", or ELFDATA2MSB (2) (System V ABI, ELF header)
UTF-16 and UTF-32 texteither, marked or labelledUTF-16BE and UTF-16LE fix the order; plain UTF-16 may start with a and is big-endian without one (below)

PNG carries the TIFF convention inside itself: its eXIf chunk holds Exif data whose first bytes are "either 'II' for little-endian (Intel) or 'MM' for big-endian (Motorola) byte order", so a decoder checks for 49 49 2A 00 or 4D 4D 00 2A, the number 42 in each order (PNG Third Edition, 11.3.4.5). WebAssembly writes its other integers in a variable-length code whose first byte carries the lowest seven bits, so its binary format is low-end-first throughout.

RFC 4506 answers the obvious complaint about XDR directly. "Why is the XDR byte-order big-endian instead of little-endian? Isn't this unfair to little-endian machines such as the VAX(r), which has to convert from one form to the other? Yes, it is unfair, but having only one byte-order means you have to be unfair to somebody." And the benefit of one order is that "data in XDR format can be written to a magnetic tape, for example, and any machine will be able to interpret it, since no higher-level protocol is necessary for determining the byte-order".

Little-endian and big-endian compared

Little-endianBig-endian
Lowest address holdsthe least significant bytethe most significant byte
0x0A0B0C0D in memory0D 0C 0B 0A0A 0B 0C 0D
Where it is nativex86 and x86-64; Arm, RISC-V and ppc64el as Debian ships themIBM z (s390x), SPARC V9, and the big-endian Power and MIPS ports
Formats that use itBMP, WebAssembly, UTF-16LE, ELF on little-endian targetsInternet headers, PNG, Java class files, XDR, CBOR, UTF-16 without a mark
What its proponents give for itsignificance grows with address, "consistent ... with mathematics" (Cohen); "more natural for hardware designers" and commercially dominant (RISC-V)the order numbers are written in, "consistent with itself and with the English language" (Cohen); the order of IP networking's data structures (RISC-V)
What it costsa hex dump shows multi-byte numbers back to front; every field of a network header has to be convertedthe little-endian processors most systems run convert every value they read from the wire or from a big-endian file

The arguments for either order are real and small; Cohen wrote that "the difference between sending eggs with the little- or the big-end first is trivial". His own list: "Serial comparators and dividers prefer the former", the big-endian order, while "Serial adders and multipliers prefer the latter". He found the little-endian order's one disadvantage aesthetic, that "English character streams appear to be written backwards" in a dump, and he observed that "only the Big-Endians of Blefuscu have built systems with a consistent order which works across chunk-boundaries", having "failed to find a Little-Endians' system which is totally consistent". RISC-V's designers chose little-endian "because little-endian systems are currently dominant commercially (all x86 systems; iOS, Android, and Windows for ARM)", added that "A minor point is that we have also found little-endian memory systems to be more natural for hardware designers", and defined big-endian variants anyway because "certain application areas, such as IP networking, operate on big-endian data structures". Their fixed little-endian instructions have a price they state too: big-endian just-in-time () compilers "must swap the byte order when storing to instruction memory".

The cost that matters most in practice belongs to neither order. It is the conversion at every boundary between them, and the bugs when one is missed. POSIX says as much about network byte order: it "may not be convenient for processing actual values", which is why values are converted to host order on the way in and back on the way out.

Middle-endian: the PDP-11

Not every machine picked one of the two. Cohen's memo describes the PDP-11 as "the first computer to claim to be a Little-Endian", storing 16-bit words low byte first, but treating its registers "in the Big-Endians' way", with the high half of a 32-bit operand in the lower-numbered register, and storing its floating-point numbers with "the wide end to the LOWer addresses in memory, and the narrow to the HIGHer addresses" while each 16-bit word stayed little-endian. The VAX did the same with its floating-point numbers, Cohen says because "it tries to be compatible with the PDP11", and its packed-decimal numbers were another case where "The Big-Endians struck again". POSIX records the result in the rationale of <endian.h>: "Many implementations also include PDP_ENDIAN to indicate a byte ordering where each pair of bytes is swapped. If BIG_ENDIAN is defined as 4321, PDP_ENDIAN would be 3412", a scheme that "derives its name from an obsolete processor". The Linux kernel's byte-order header still mentions "pdp endian machines" in a comment, and its two byte-order headers define __LITTLE_ENDIAN as 1234 and __BIG_ENDIAN as 4321 in the same notation.

The bugs it causes

None of these raises an error; each produces a valid number that is the wrong one.

  • A port in host order. struct.pack("H", 80) on a little-endian host gives b'P\x00', and the network reads the two bytes 50 00 as port 20 480. The C version is a sin_port filled without htons(). The fix is the ! prefix in Python, "network (= big-endian)" in the struct documentation, or the conversion function in C.
  • An address as an integer. 192.0.2.10 is 3 221 225 994 in network order and 167 903 424 when its bytes are loaded raw on a little-endian host. A database column, a log field or a hash table that stores one and is read as the other points at a different machine.
  • Bytes reinterpreted through the wrong type. POSIX warns that data to be converted "should either be received directly into a uint16_t or uint32_t object or should be copied from an array of bytes using memcpy() or similar. Passing the data through other types could cause the byte order to be changed."
  • Text in the wrong order. The UTF-16BE bytes 00 48 00 69 are "Hi"; decoded as UTF-16LE they become 䠀椀 (U+4800 and U+6900), with no error, measured in CPython 3.13.16.
  • A hash that depends on the processor. Any code that hashes the raw bytes of a multi-byte field without converting it computes a value that depends on the processor. Linux's bonding driver does exactly that, and the section on (Link Aggregation Control Protocol) below shows when it moves a flow.
  • Native formats written to disk. Python's struct defaults to "the machine's native format and byte order", and its documentation adds that "There is no way to indicate non-native byte order (force byte-swapping); use the appropriate choice of '<' or '>'." A file written with the default on one machine is misread on the other.

How to tell what a machine is

  • Python: sys.byteorder "will have the value 'big' on big-endian (most-significant byte first) platforms, and 'little' on little-endian (least-significant byte first) platforms" (Python, sys). For a single field, int.from_bytes() and int.to_bytes() take the order as an argument that "defaults to 'big'" (Python, built-in types), and array.byteswap() is "useful when reading data from a file written on a machine with a different byte order" (Python, array).
  • The site's Python playground: it runs CPython compiled to WebAssembly, and WebAssembly memory is little-endian whatever the processor underneath, so the playground answers little on any machine. Its engine, Pyodide 314.0.7 with CPython 3.14.2, reports wasm32 as the machine and packs 0x0A0B0C0D natively as 0d 0c 0b 0a.
  • Linux, from the shell: lscpu prints a "Byte Order" line, "Little Endian" or "Big Endian" (util-linux, lscpu.c). It reads /sys/kernel/cpu_byteorder, which the kernel has offered since 6.2 as "The endianness of the running kernel", "little" or "big" (Linux ABI documentation), and falls back to the compiler's own byte-order macro (util-linux, lib/sysfs.c). On the x86-64 machine these examples ran on, util-linux 2.39.3 printed Byte Order: Little Endian.
  • C: POSIX's <endian.h> defines BYTE_ORDER, equal to LITTLE_ENDIAN or BIG_ENDIAN, and "suitable for use in #if preprocessing directives".
  • A binary: the sixth byte of an ELF file (e_ident[5]) is 1 for little-endian and 2 for big-endian. On the same machine od -t x1 -N 8 /bin/ls showed 7f 45 4c 46 02 01 01 00, and readelf 2.42 spelt the 01 out as Data: 2's complement, little endian.
  • A file of text: look for a byte order mark at the start, FE FF or FF FE in UTF-16.

Three cases on this site

The LACP hash

Linux's bonding driver picks the member link for a frame by hashing its addresses, and it does so on the bytes as the processor loads them. In bond_ip_hash the two IPv4 addresses are XORed as raw 32-bit values, (__force u32)flow_get_u32_dst(flow) ^ (__force u32)flow_get_u32_src(flow); for layer3+4 the starting value is the two ports copied straight from the header, memcpy(&hash, &flow.ports.ports, sizeof(hash)); the result is folded twice (hash ^= (hash >> 16); hash ^= (hash >> 8);) and shifted right by one; and the member is slaves->arr[hash % count] (Linux, drivers/net/bonding/bond_main.c). Only the that layer2 and layer2+3 mix in goes through be16_to_cpu() and comes out the same on every processor. So an x86-64 server and an IBM Z guest (s390x) running the same kernel compute different hash values for the same flow.

Whether the flow then lands on a different member depends on how many members there are. The two folds leave in the lowest byte of the hash the XOR of all four bytes of the word, which is the same in either order, and a modulo by two, four or eight, even after layer3+4's final shift, reads only bits that came from that byte. Counted over 100 000 flows with random addresses, ports and MAC addresses on 2026-11-08, under layer2+3 and layer3+4 alike, the two byte orders chose the same member every time with two, four or eight members, and a different member for about two flows in three with three or six members, four in five with five and six in seven with seven. A flow from 192.0.2.10 port 50002 to 198.51.100.20 port 873 over TCP, layer3+4, hashes to 0x3B8939DB on a little-endian processor and 0x62D260DB on a big-endian one: with four members both use member 3, with three members the little-endian machine uses member 1 and the big-endian machine member 2. The LACP member link and state reader computes both, step by step, and Link aggregation and LACP explains the hash itself.

The BIG-IP persistence cookie

A BIG-IP cookie of the default IPv4 form looks like 1677787402.20480.0000. F5's own explanation of the port field is a byte-order recipe: "the port number is converted the same way as the IP address. You convert to hexadecimal, then reverse order the hex numbers, then convert to decimal" (F5 DevCentral, Lightboard Lessons: BIG-IP Cookie Persistence Values). F5's support article states it as an algorithm: "Reverse the order of the hexadecimal bytes and concatenate to make one 4-byte hexadecimal value", which for the address a.b.c.d is a + b*256 + c*(256^2) + d*(256^3), and the two port bytes are reversed the same way (F5 K6917). Worked through, 10.1.1.100 is the bytes 0A 01 01 64, and those four bytes read little-endian are 0x6401010A, 1 677 787 402; port 80 is 00 50, and read the same way it is 0x5000, 20 480. In other words, each field is the integer a little-endian processor gets by loading the address and port bytes, in network order, without converting them. The four BIG-IP cookie encodings decodes every form, including the route-domain and IPv6 ones, and the cookie decoder does it for any value.

UTF-16

A UTF-16 code unit is two bytes, so UTF-16 text has a byte order. Unicode defines three encoding schemes for it: UTF-16BE, UTF-16LE, and UTF-16, which may begin with a byte order mark: "An initial byte sequence <FE FF> indicates big-endian order, and an initial byte sequence <FF FE> indicates little-endian order", and "when there is no BOM, and in the absence of a higher-level protocol, the byte order of the UTF-16 encoding scheme is big-endian" (Unicode 18.0.0, chapter 3, D98). RFC 2781 says the same, that text without a mark "SHOULD be interpreted as being big-endian". Browsers do the opposite: in the WHATWG (Web Hypertext Application Technology Working Group) Encoding Standard the label "utf-16" names UTF-16LE, and "the byte order mark is more authoritative than anything else" (WHATWG Encoding Standard). Python's "A".encode("utf-16") writes a mark and then the host's order, b'\xff\xfeA\x00' on the little-endian machine of these examples, as Python's bytes and text shows; UTF-8, UTF-16 and UTF-32, byte by byte reads the marks in a hex dump, and the charset converter decodes the same bytes in each order.

What to remember

  • Byte order is only about numbers wider than a byte: single bytes, ASCII text and UTF-8 look the same either way.
  • Big-endian puts the high byte first and is the Internet's order; little-endian puts the low byte first and is what x86-64 and most Arm systems run.
  • Convert at the boundary and name the direction: htonl, be32toh, cpu_to_be32, struct's !. Code written that way is right on both kinds of machine.
  • Formats either fix an order (PNG, Java class files, XDR, CBOR big; BMP, WebAssembly little) or mark it (TIFF's II and MM, ELF's EI_DATA, the UTF-16 byte order mark).
  • A byte-order bug never raises an error; it yields a valid wrong number, a port of 20 480 or a text in the wrong script.
  • As Cohen put it in 1980, agreeing on an order matters more than which order is agreed on.

Sources

The definitions and network byte order are POSIX's (Issue 8, 2024) and the RFCs'; the processors' orders are each architecture's own manual, except MIPS, which is described from the Linux kernel's configuration because no manual hosted by its could be found, and Arm, whose registers and instructions are Arm's own pages and whose practice is described from the Linux kernel's configuration files; F5's support article and Arm's pages were read in a browser, those sites refusing automated reads; the file and protocol orders are their specifications'. The Python, Pyodide, lscpu, od and readelf results and the hash counts were measured on 2026-11-08 on an x86-64 machine, the hashes with a short Python model of bond_main.c checked against the site's LACP engine. Every document below was read on 2026-11-08.