Little and big endian are two ways of storing multibyte data-types.

For LittleEndian, important bytes are stored at the smallest address. It is reverse order from a human perspective.

For BigEndian, important bytes are stored at the biggest address. It is a normal order from a human perspective.

For example, an integer is stored as 4 bytes then a variable Awith value 0x01234567 will be stored as follows.

Intel processors use the little-endian format for storage. I always wonder why someone would want to store the bytes in reverse order. I always wonder the Arabic Alphabet too.

Little-Endian is also known as the “Intel convention”. As Intel used the little-endian format from it’s earlier processors. It has advantages on easier mathematical computation. Mathematical operations mostly work from LSB.

Big endian is widely used for network transmission. So it is called “network byte order”. Big-Endian is also known as the “Motorola convention”.Back then as it was widely used by Motorola processors. It is human-readable format as it is one to one mapping. Bytes are in the same order as we write.

The question of which one is better is a controversial subject. The answer depends on your aim, just as the novel named Gulliver’s Travels. Words Little Endian and Big Endian are originated from the 1726 novel Gulliver’s Travels by Jonathan Swift. In which civil war breaks out over whether the big end or the little end of the egg is proper to crack open. Words Little Endian and Big Endian are used to name two groups who fight over little end and the big end of the egg is the proper way to break egg receptively.

You can find detailed information in this URL below.

https://getkt.com/blog/endianness-little-endian-vs-big-endian/

Finally, here are some Golang codes about Big and Little Endian conversions.

package main

import (
“bytes”
“encoding/binary”
“fmt”
)

var num int32 = 12345

func main() {
var bufL, bufB bytes.Buffer

binary.Write(&bufL, binary.LittleEndian, num)
binary.Write(&bufB, binary.BigEndian, num)

fmt.Println(“little endian:”, bufL.Bytes())
fmt.Println(“big endian:”, bufB.Bytes())

}

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