Beetwise

Big endian and little endian

Endianness sets the order of the bytes of a value in memory.

Big endian puts the most significant byte at the lowest address.

Little endian puts the least significant byte at the lowest address.

Try byte order in the bit editor

The value 0x1234 in a 16-bit register. Edit the expression or select a bit to flip it.

15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0x1234
hex · 16 bits
value
4660
Bit width
Byte order

Byte order step by step

Store the 16-bit value 0x1234 in memory: The steps follow the value above.

  1. Write the value as bytes: 12 34
  2. Reverse the order of the bytes.
  3. The result is 34 12.
  4. In hex, 0x1234 becomes 0x3412.

The value 0x1234 in each byte order

The value 0x1234 in each byte order
Byte orderFirst byteSecond byte
Big endian0x120x34
Little endian0x340x12

Where byte order is used

Most desktop processors and the ARM cores in common microcontrollers use little endian order.

Many network protocols use big endian order, which is also called network byte order.

A wrong byte order gives a value that looks random but is in fact reversed.

Byte order: points to note

  • Endianness applies to bytes, not to the bits inside a byte.
  • A value of one byte has no byte order. Endianness starts at a bit width of 16.
  • A serial protocol must state its byte order. Two devices with different orders cannot exchange values.

The full bit editor

The full editor holds many values, evaluates expressions across them, and reads live values from a serial port.

Open this value in the full editor

Questions about byte order

Which order does my processor use?
An x86 processor and most ARM cores use little endian order. Check the data sheet for another architecture.
What is network byte order?
Network byte order is big endian. The functions htons and htonl convert a value into this order.
Does endianness change the bits?
No. The bits of the value stay the same. Only the position of each byte in memory changes.