Data Representation: Bits, Bytes & Numbers

the sign bit, MSB, and LSB

/ em-ess-bee, el-ess-bee /

Inside a multi-bit number, not all bits are equal. Just as the leftmost digit of 1000 matters far more than the rightmost, the bits of a byte have differing weight. The most significant bit (MSB) is the one with the biggest place value — the 'top' bit — and the least significant bit (LSB) is the one worth the least, the 'bottom' bit worth just 1. Naming them lets us talk precisely about which end of a number we mean.

In an ordinary 8-bit unsigned byte, the MSB is worth 128 and the LSB is worth 1. We usually draw numbers with the MSB on the left and the LSB on the right, mirroring how we write decimal. The LSB has a charming everyday use: it instantly tells you whether a number is even or odd, because the lowest bit is the '1s place' — if the LSB is 0 the number is even, if 1 it is odd, which is why 'x & 1' is the classic odd-test. The MSB earns a special role too: in a SIGNED number it is the sign bit, where 0 means non-negative and 1 means negative.

So the MSB wears two hats depending on interpretation. Read a byte as unsigned and its top bit is just the 128s place, an ordinary value bit; read it as signed two's complement and that same top bit becomes the sign, carrying negative weight. This is yet another face of 'pattern versus interpretation', and it is why shifting and masking the top bit needs care: whether the top bit means '+128' or 'this is negative' depends entirely on the type you are using.

In the byte 1000 0001: the MSB (leftmost) is 1, the LSB (rightmost) is 1. As unsigned this is 129; as signed two's complement it is -127. The LSB being 1 means the value is odd.

MSB = top/biggest bit (and the sign bit when signed); LSB = bottom 1s bit.

MSB and LSB describe bit POSITIONS within a number; do not confuse them with most/least significant BYTE, which is about endianness — the order whole bytes are stored in memory.

Also called
most significant bitleast significant bithigh bit符號位元