What is a bit, nibble or Byte?

First, Back to Basics

To understand bits, nibbles and bytes we have to revisit the idea of number systems. Remember in elementary school when you had to break numbers into their ‘places’? Take for example, the number 123, you have a 1 in the hundreds place, a 2 in the tens place and a 3 in the ones place leaving you with

Number 1 2 3
Place Value 100 10 1

(1 * 100) + (2 * 10) + (3 * 1) = 123.

This is known as the base 10 number system. In the base 10 system each place is represented by 10 to the power of the place number minus one. The simplest way to remember this is just that the first place number is 0 and 10^0 is 1, therefore represents the ones place.

A 3 digit number has 10^3 or 1000 possible values, since our range starts at 0 it ends with 999 which makes sense because in the base 10 system, each place can hold a value of 0 to 9.

Now Back to Bits

Bits (Binary digITS) have a value of either 0 or 1 and since they have two possible values for each place this is known as the base 2 number system. Just as with base 10 having 10 to the power of the number of places, base 2 has 2 to the power of the number of places.

For example, a 3 digit number in base 2 has 2^3 or 8 possible permutations. So, while a three digit base 10 number has a range of 0-999, our three digit base 2 number only has a range of 0-7.

As one more example, let’s look at a binary number.

1111011

This might look confusing at first but it’s actually very simple, you can convert this value to decimal by simply looking at the value in each of the places.

The leftmost place is the 7th position and therefore represents 2^6 (remember place minus one) or 64. So, we have the following places respectively 64, 32, 16, 8, 4, 2, 1. We will skip the zeros since there’s no point in adding zeros, that leaves us with a 1 in the 64, 32, 16, 8, 2 and 1 place and we simply add them all up.

64 + 32 + 16 + 8 + 2 + 1 =  123

Look at that, it’s the same number from our base 10 example.

Why Use Base 2

Since computers are digital, data is stored in bits represented by physical components but those physical components don’t easily represent digits in a decimal style system. Two-state devices were found to be the easiest and least complex way to represent data, Some examples of these physical two state devices are

  • Punch cards with a hole or no hole in specified sections
  • Electrical circuit with a high or low voltage
  • Magnetic strip with magnetized or demagnetized sections.

Punch cards have been phased out, magnetized strips are on there way to being phased out with the advent of cheaper solid state devices but there are still plenty of magnetic storage devices out there.

Nibbles

We’ve learned a little about bits, the next step up is called a nibble. A nibble is a collection of bits, specifically it is 4 bits. Knowing about bit permutations we can easily figure out that 4 bits has a range of 0-15 and therefore a nibble can hold any value within that range.

Nibbles are not used too often but in the event you hear someone or read something referring to a nibble hopefully you’ll remember that it’s a collection of 4 bits. Nibbles may also be referred to as nybbles because they use the y to resemble the term byte which is the next topic of discussion

Bytes

A byte is a collection of 8 bits, therefore a byte is two nibbles, get it? A nibble is half of a byte so that might be one easy way of remembering. Anyway, bytes are the most commonly referred to measurement of data storage, think bytes, kilobytes, megabytes, gigabytes and this day in age terabytes is also a common measurement.

Fun Factoid: While a byte is exclusively known today as being attributed to a collection of 8 bits, the term byte is actually a name that refers to the number of bits required to encode a single character on a particular system. Way back in the day, some computer systems contained 6 bit bytes, 7 bit bytes, etc but rest assured, these days a byte is exclusively 8 bits.

Since a byte is 8 binary digits we can determine that a byte has a range of 0-255. A byte can hold one alphanumeric character in the ASCII standard. This typically represents every key on the standard American keyboard as well as a few extras. The way this is done is through the ASCII code which maps each character to a base 10 value which can be stored in a byte as a binary value. Notice the ASCII table below, this table is not the extended version so it only shows the more common values.

ascii-table

Say you wanted to store the letter ‘a’ in memory. Looking at the table, a lowercase ‘a’ is represented by the decimal value of 97. So, we simply convert this 97 to a byte and it can be relatively easily stored in a digital circuit.

Converting from base 10 to base 2 is a little trickier than the other way around. First, lets clearly establish that we’re trying to store this value in a byte, an 8 binary digit value so at the very least we know we’ll have a value 8 binary digits long. Let’s start by placing zeros in every placeholder.

0 0 0 0 0 0 0 0
128 64 32 16 8 4 2 1

This set of places represents the place values 128, 64, 32, 16, 8, 4, 2, 1 respectively.

Now, we can step through each place and if the value of that place is less than the number we have, we put a 1 there. First up, we have 128 but that’s larger than 97 so leave that a zero. Next we have 64 which is smaller than 97 so let’s put a 1 there.

0 1 0 0 0 0 0 0
128 64 32 16 8 4 2 1

Since we’ve now placed a 1, we can subtract that value from our original number, we get 97-64=33. And we repeat the process, the next place is 32 which is smaller than 33 so we put a 1 there as well.

0 1 1 0 0 0 0 0
128 64 32 16 8 4 2 1

Now our remaining value is 33-32=1 but rather than needing to step through, we can simply skip down to the first position because the only place that can hold a 1 or smaller is the first position, and here is our final result.

0 1 1 0 0 0 0 1
128 64 32 16 8 4 2 1

01100001 = 97 = a

In simple terms, this is what your keyboard does, when you press the ‘a’ key it is mapped to a specific value and sent to the computer as a digital signal. In reality it’s commonly more complex than that but a device that sends serial ASCII data can certainly be hooked up to an oscilloscope to view the signal which will look similar to the value of the byte we just converted to binary but that’s a topic for another time.

If Kilo is 1000, why are there 1024 bytes in a KB?

This one is an interesting one but with a pretty simple answer. Kilo means 1000 but this is a metric term and the metric system is based on the base 10 number system. Basically, the metric terms were borrowed and applied to the base 2 number system. In actuality the closest binary number to 1000 is 1024 (2^10). Unfortunately, this only makes things more confusing with larger metric terms because the issue is compounded. For example, 1 gigabyte (GB) is equal to 1024MB and each MB is 1024KB and each KB is 1024 bytes. So, 1GB is 1024MB * 1024KB * 1024B which means a gigabyte which would normally mean 1,000,000,000 is actually 1,073,741,824 and it’s only going to get worse as these storage sizes increase. The one good thing is that the difference is somewhat minimal but it’s also in your favor, you think you have 1GB but you actually have 1.074GB

So now, when you run an internet speed test you’ll know what the speed really means. This is a convenient segue into the last topic I’d like to cover and that is the abbreviation of bit vs byte. Bytes are typically referred to with a capital B and bits with a lowercase b so when you’re running that speed test and it says 20Mb/s it actually means megabits per second and since you know there are 8 bits in a byte, if you want the megabyte (MB) download speed you actually have to divide that Mb number by 8. A download speed of 20Mb/s is equal to 2.5MB/s. Hopefully that helps explain why you have a 20Mb internet speed but always seem to download at rates of around 2 megabytes per second.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *