Published in


One Little Two, Little Three … Little-Endian

The Byte Order In Bit Processing

Little-Endian, Big-Endian

The order of bytes in a binary representation of a number is called endianness, and there are two types. There is the Little-Endian and the Big-Endian. In Little-endian ordering, the most significant byte (MSB) is placed last and the least significant byte (LSB) is placed first. This is the opposite of Big-endian ordering (significant byte first, least significant byte last).

The byte order is how the machine organizes strings of code, whether to read it from most significant or least significant byte. Bytes consist of 8 bits and when we have a collection of bytes we have a word. A word can be 8, 16, 32 or 64 bits long. The consideration of byte order has a lot to do with low level machine assembly language. This determines the order on how to process the word in computers.

Little-Endian is another way of saying the “Little End”, while Big-Endian is the “Big End”. The “Little End” stores the least significant byte in a word, while the “Big End” stores the most significant byte. The byte’s order determines its significance. In the byte order, the lowest address in the word is treated as the MSB when using the Big-Endian notation. The lowest address is the LSB when using the Little-Endian notation.

Here is an example:

This is a 32-bit word 18253453. In hexadecimal notation it would be written as 0x0116868D.

Now let us convert it into binary:

00000001 00010110 10000110 10001101

These values are stored in contiguous sequence in memory locations. Each byte has a position in the byte order determined by its power of 2. The most significant byte has the largest powers of 2 while the least significant byte has the smallest powers of two in positional notation. Going back to our example, the most significant byte would be 0x01 while the least significant byte is 0x8D.

Each square represents the memory location or register where the value is stored. In a Big-Endian machine, the most significant byte is read first with a stored value of 01 while the Little-Endian machine will read the least significant byte with a value of 8D. The Big-Endian reads the MSB as the lowest address at the register that stores 01, while the Little-Endian reads the LSB at the lowest address at the register that stores 8D.

From Python, you can determine the endianness of your machine.

>>> import sys>>> dir(sys)['__displayhook__', '__doc__', '__excepthook__', '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_debugmallocstats', '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'api_version', 'argv', 'base_exec_prefix', 'base_prefix', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_wrapper', 'getallocatedblocks', 'getcheckinterval', 'getdefaultencoding', 'getdlopenflags', 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval', 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info', 'intern', 'is_finalizing', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'set_asyncgen_hooks', 'set_coroutine_wrapper', 'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'thread_info', 'version', 'version_info', 'warnoptions']>>> sys.byteorder'little'

In the above example, I am using an x86 architecture processor which uses the Little-Endian byte order with the return value of ‘little’. On other machine architectures, it will return a value of ‘big’.

The important thing to remember is that Little-Endian machines store bytes ordered from LSB to the MSB. Big-Endian machines store bytes ordered from the MSB to the LSB.




Essays and Articles on software engineering, development and computer science.

Recommended from Medium

Theming in SASS

Shuffling algorithms and randomization to improve algorithm‘s runtime.


Build a Python GUI calculator in 5 minutes

New Alchemy Security Audit: Findings

How to detect locks on Redshift

Set-up OSM Rails port/Database

Enterprise Serverless 🚀 (Series)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Tabora

Vincent Tabora

Editor HD-PRO, DevOps Trusterras (Cybersecurity, Blockchain, Software Development, Engineering, Photography, Technology)

More from Medium

Decompilers: Ethical or Unethical?

Operator Overloading in VHDL

Operating System:Deepin OS Becomes the First Linux Distro to Offer Face Unlock

How to prepare a meta toolchain for Qt with Yocto Project