Is the least significant bit (LSB) always the "first" bit?

Viewed 3161

I'm reading Modern C (version Feb 13, 2018.) and on page 42 it says

Image captured on page 42 of the book

It says that the bit with index 4 is the least significant bit. Isn't the bit with index 0 should be the least significant bit? (Same question about MSB.)

Which is right? What's the correct terminology?

3 Answers

Their definition of "most significant bit" and "least significant bit" is misleading:

8 bit Binary number : 1 1 1 1 0 0 0 0
      Bit number      7 6 5 4 3 2 1 0
                      |     |       |         
                      |     |       least significant bit
                      |     |
                      |     |
                      |     least significant bit that is 1  
                      |
                      most significant bit that is 1 and also just most significant bit

They're using an unusual definition of LSB and MSB, which only refers to the bits that are set to 1. So in the case of 240, the first 1 bit is b4, not b0, because b0 through b3 are all 0.

I'm not sure why the book considers this definition of LSB/MSB to be useful. It's not generally interesting for integers, although it does come into play in floating point. Floating point numbers are scaled so integers above 1 have the low-order zero bits shifted away, and the exponent is incremented to make up for this (conversely, fractions have their high-order bits shifted away, and the exponent is decremented).

The book's definition does not align with common/typical/mainstream/correct usage. See Wikipedia, for instance:

In computing, the least significant bit (LSB) is the bit position in a binary integer giving the units value, that is, determining whether the number is even or odd.

The book, on the other hand, seems to consider only bits that are 1, so that in an 8-bit byte representing the number 16, which we can write:

00010000

the bit that is 1 has index 4 (it's b4 in the book's notation), and then it claims that that particular number's LSB is four.

The proper definition just uses LSB to denote that bit whose value is 1, i.e. the "units", and with that the LSB is the rightmost bit. This latter definition is more useful, and I really think the book is wrong.

Related