Bit and Byte Numbering

LSB: Least Significant Bit

MSB: Most Significant Bit

Bit Numbering Schemes:

There are 2 common bit numbering schemes LSB0 and LSB1:

LSB0:

Starts with LSB as 0 and goes to MSB as 7

LSB1:

Starts with LSB as 1 and goes to MSB as 8.

In other words:

  • A bit has two values (on or off, 1 or 0)

  • A byte is a sequence of 8 bits:

    • The "leftmost" bit in a byte is the biggest. So, the binary sequence 00001001 is the decimal number 9. 00001001 = (23 + 20 = 8 + 1 = 9).

    • For LSB0, Bits are numbered from right to left. Bit 0 is the rightmost and the smallest; bit 7 is the leftmost and the largest

    • For LSB1, Bits are numbered from right to left. Bit 1 is the rightmost and the smallest; bit 8 is the leftmost and the largest



The referring to the first bit or the last bit is not clear and is to be avoided. Likewise, the leftmost bit should always be referred to as "bit 7" for LSB0 instead of "the leftmost bit" etc.

Byte Numbering:

Many will just count bytes starting from the left to right. You will see people start with 1 or 0. So, in the following example, 12 is the first byte and could be referred to as Byte 0 or Byte 1. A C-programmer would probably refer to it as Byte 0 because that is the way memory is addressed in C. Someone who is not a C-programmer might call it Byte 1.  Byte 0 is probably more well-accepted.

As for how to store a number or data in such a system, you have to know if it is stare Big Endian or Little Endian. 

  • Big endian machine: Stores data big-end first. When looking at multiple bytes, the first byte (lowest address) is the biggest.

  • Little-endian machine: Stores data little-end first. When looking at multiple bytes, the first byte is the smallest.

For Example:

Byte Name: W X Y Z Location: 0 1 2 3 Value (hex): 0x12 0x34 0x56 0x78

  • Big-endian machine: An int is 4 bytes, and the first is the largest. I read 4 bytes (W X Y Z) and W is the largest. The number is 0x12345678.

  • Little-endian machine: Sure, an int is 4 bytes, but the first is the smallest. I also read W X Y Z, but W belongs way in the back -- it's the littlest. The number is 0x78563412.