# What is the use of MSB and LSB? [duplicate]

I have a hard time understanding the use of MSB (Most significant bit) vs. LSB (Least significant bit) and why they're used at all. It is my understanding that it has to do with Endianness, but I cannot get my head around it.

Basically: If I read a specification on X and they specify that the data needs to be read LSB or MSB - ok I can do that - but why am I doing it.

Why don't we just send all data MSB?

## marked as duplicate by Robert Harvey♦, durron597, user22815, Ixrec, user40980 Aug 14 '15 at 0:04

• – gnat Aug 13 '15 at 20:51
• Thank you guys, for both links. I'll read them straight away :) – Michael Aug 13 '15 at 20:53
• Short answer: they're good for provoking endian wars. – GlenH7 Aug 13 '15 at 20:59
• Sigh. A few shared keywords does not a duplicate make. – Karl Bielefeldt Aug 13 '15 at 22:03
• @KarlBielefeldt - A few short sentences do not a good question make. I agree that there's potential behind this question, but it's not clear what the OP doesn't understand. Given the multitude of information already available regarding MSB, LSB, and {big | little} endian, the community is left with a guessing game as to the actual question. The OP's comment is / was highly indicative of the suggested duplicate answering their question. – GlenH7 Aug 14 '15 at 15:04

Endianness for binary (base 2) is no different than endianness for any other base.

Without a specification telling you which side the most significant and least significant decimals were, you wouldn't know whether

``````1234
``````

is one-thousand-two-hundred-and-thirty-four or four-thousand-three-hundred-and-twenty-one.

Note for additional curiosity that "twenty-one" is MSD whereas "nineteen" is LSD, so it's certainly not that universally obvious even within the same community which one is the right one.

For dates, there are three different conventions (using Alan Turing's birthday as example):

• least significant component first (e.g. in Germany): 23.06.12
• most significant component first (e.g. ISO): 12-06-23
• complete and utter confusion (US): 06/23/12

Again, you have to pick some order, and you have to communicate which order you picked, and there is no obviously "right" order. (I would argue though, that the US date format is obviously wrong :-D .)

• Well explained, thank you. Together with your other comment, I drew the same conclusion in regards to why we don't just send data the same way (MSB or LSB) - why don't we all speak english? That must be the same answer in the end. I'm looking for an answer to "why was LSB created then..", but I could keep asking myself these things I guess - why was the French language "created", and keep going until the end of time :). Thanks again! Helps a lot. – Michael Aug 13 '15 at 21:51
• LSB wasn't "created". It just exists. It is an equally valid and equally sensible way to send data. Left-side driving wasn't "created", right-to-left and top-to-bottom writing systems weren't "created". It is completely and utterly irrelevant which side of the road you drive on, as long as you and the person coming towards you agree. There is absolutely no reason for one or the other. It is irrelevant whether you write left-to-right or right-to-left or top-to-bottom, there are no inherent advantages or disadvantages. – Jörg W Mittag Aug 13 '15 at 22:02
• @JörgWMittag great answer! But to play Devil's advocate, there is arguably the disadvantage for a right-handed person that they would be more likely to smudge if they write right-to-left with a quill and ink, no? – Carson63000 Aug 14 '15 at 0:02
• @Carson63000: I thought about including that. (I'm a leftie, thus very much aware of the issue!) That would then be an obvious advantage for top-to-bottom, since that works equally well for both lefties and righties. – Jörg W Mittag Aug 14 '15 at 1:04
• Thankfully, the ISO 8601 chose a sane date format: YYYY-MM-DD :) – Petrus Theron Mar 11 at 20:11

When a byte is serialized into a stream of bits and transmitted serially, it becomes important to know whether it's transmitted LSbit-first or MSbit-first. The transmitter can send the bits in either order, and the contract whether it's LSbit-first or MSbit-first is established in the spec (or datasheet). For example, the receiver receives this:

``````time: 01234567
bit:  01000000
``````

If the transmitter was sending LSbit-first, then the value is `0x02`. If the transmitter was sending MSbit-first, then the value is `0x40`. The receive has to know which one it is.

• That makes sense, and I understand that - but what I'm confused about is (and that might be a long subject), why the two different types of contracts? Why do we not always send data MSB. Is it based on the type of "machine" that is sending? – Michael Aug 13 '15 at 21:22
• Because you can do it both ways, and there is no overwhelming reason to do it one way or the other. Both have their advantages and disadvantages. Historically, computer manufacturers weighed the advantages and disadvantages differently, and arrived at different trade-offs. Note that this is also true in the English language ("nineteen" is least-significant-decimal first, "twenty-one" is most-significant-decimal first), or in date formats (ISO is year-month-day, i.e. most-significant-component first, German is day.month.year, i.e. least-significant-component first and US is month/day/year, … – Jörg W Mittag Aug 13 '15 at 21:47
• … which makes no sense at all). – Jörg W Mittag Aug 13 '15 at 21:48

Bit order and byte order are two separate things, but they may affect your preferences. Say you have a little-endian machine, and you want to transmit a 32-bit number. Also transmitting the bits LSB-first means overall bit order for the entire int (with lsb numbered 0) is:

``````0 1 2 3 4 5 6 7 8 9 10 11 12 ... 31
``````

If you transmitted MSB-first, the overall bit order for the entire int would be:

``````7 6 5 4 3 2 1 0 15 14 13 11 ... 24
``````

Looking at this signal on an oscilloscope just got more difficult, and designing shift registers in hardware just got a little more tricky.

The reverse occurs for big-endian machines. So endianness doesn't dictate bit order, but it sure does make one bit order easier to work with.

As far as preferring one endianness over another, it's more than picking one at random. Big endian is easier to understand conceptually, but little endian means you don't have to offset the address in order to treat a byte as a word.

MSB and LSB can be thought of in terms of numeric properties of bit sequences. For example, during addition, the carries flow from the addition of two LSB's toward the next higher bit. The LSB itself receives no carry because it starts the addition; whereas all the other bits get a carry from the next least significant bit position. Overflow is when a carry (of value 1) happens from the MSB, because there are no more bits (in the byte or word size) left to carry over to. The MSB is also considered the sign bit for signed data types: if the MSB is 1 the value is negative, if 0 the value is positive (or zero).

Endianess is a matter of the storage (or transmission) order for bits within a byte and also more significantly (as it turns out) for the order of bytes within a word or long word. These differences can be seen when data is moved from one system to another. Fortunately bit order within a byte is standardized on hard drives and networks, so we don't have to worry about bit endianess. However, byte order within a word is different for some processors than others, and bytes become swapped when changing architectures; as this causes problems it requires mitigation (e.g. software has to handle it). Little endian stores least significant bytes first followed by more significant bytes in higher storage or packet address order, whereas big endian is the opposite.