This post is the 3rd in a series about basic concepts in programming and Computer Science. You can find all the posts in the series below.

  1. CS Basics: Binary Conversion
  2. CS Basics: Hex and 32 Bit Conversion
  3. CS Basics: Detour - Nibbles, MSB, and LSB
  4. CS Basics: Converting Between Different Bases

Up until now, I’ve been representing binary, quaternary, octal, and hexadecimal numbers a little incorrectly. I did this so we wouldn’t be dealing with too many concepts at once. So, let’s take a detour and look at the way binary numbers are traditionally represented.

Binary numbers are, at least in computer science, represented in groups of what’s called a nibble. A nibble is half of a byte. Because a byte is 8 bits, a nibble is 4 bits.

Each digit of a binary number represents a bit, but we don’t really represent binary numbers with a single digit. Instead, we represent all digits of a binary number in groups of 4 bits.

Since each bit can hold a maxinum of two values, a nibble can represent a range of 16 values from 0 - 15.

A Table of Nibbles

N2 Nibble
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1

So, now that we know binary numbers are represented in nibbles, we can talk about the Least Significant Bit, or LSB, and the Most Significant Bit, or MSB.

For binary integers, the LSB is the bit position that gives the units value. If this were decimal, that would be the ones.

The MSB is the bit position that gives the highest value for that binary integer.

N10 MSB LSB
10 1 0 1 0
11 1 0 1 1

The integers in the table above are, of course, only showing 4 bit numbers. The principle still stands for larger 1 byte numbers, though.

N10 MSB LSB
150 1 0 0 1 0 1 1 0

Usually the LSB is shown at the first position, in our case that’s all the way to the right. The MSB is shown in the last position, or all the way on the left. There are some differences in the way some processors have handled this but we don’t need to get into that for this post.

That’s it for nibbles, LSB, and MSB! We can get into converting between different bases on the next post.

After that, I’ll write about using bitwise operators with our different numbering systems so we can take full advantage of our newfound knowledge.