Binary Digits and Bytes

This lesson introduces you to the rules of the binary system and binary to decimal conversions.

What is a binary digit?

A binary digit, also known as a bit, is the smallest unit used to represent data or information. You can think of a bit as a binary switch. A switch has two states, ON and OFF. ON means that the current is flowing through the switch. OFF means that the current is not flowing through the switch, as shown in Figure 1. Likewise, one binary digit can represent two different states, 1 and 0, which correspond to ON and OFF in a switch, respectively. Alternatively, it can be said that one bit can store one of the two values, 0 or 1.

Figure 1: Two states of an electrical switch.
Bit 1 Bit 2 Decimal
0 0 0
0 1 1
1 0 2
1 1 3

Table 1: Four configurations using two bits.

To store a bigger value, all you have to do is increase the number of bits. Adding another bit can give you the four configurations in Table 1, which correspond to the decimals 0, 1, 2, and 3. Likewise, three bits can store or represent eight different configurations or eight decimal numbers, ranging from 0 to 7.

If you observe the pattern here, you realize that the number of configurations increases exponentially as a power of 2.

For one bit, there are 21=22^1 = 2 total configurations. Similarly, for two bits, there are 22=42^2 = 4 total configurations. Hence, it can be deduced that for x-number of bits, the total number of configurations is 2x2^{x}. Imagine having a total of at most 10 bits. The amount of numbers they can store or represent is 2102^{10} = 1024.

Binary numbers.

Each binary configuration having x-number of bits is called a binary number and has a decimal equivalent as shown in Table 1. An example of a 66-bit binary number is shown in Figure 2. Since it is made up of 6-bits, there are 26=642^6 = 64 different configurations possible and therefore, a 6-bit binary number can store 64 different numbers from 0 to 63.

Binary Number Notation: 1101012110101_2

The right most bit is called the least significant bit, and the left most bit is called the most significant bit. The first 8 binary numbers are shown in Figure 3.

Figure 2: A binary number made up of 6 bits.
Figure 3: Binary numbers representing eight configurations.

Binary to decimal conversion.

To find the decimal equivalent of a binary number, add all the terms that result upon expanding the binary number into a power series with a base of 2 starting with the least significant bit. For example, the binary number 1101012110101_2 can be expanded in the following way:

1×25+1×24+0×23+1×22+0×21+1×20=531\times2^{5} + 1\times2^{4} + 0\times2^{3} + 1\times2^{2} + 0\times2^{1}+ 1\times2^{0} = 53

When a bit is equal to 1, it contributes to the sum during the conversion whereas when it is equal to 0, it does not contribute to the sum. Therefore, just count the powers of 2 that correspond to 1s in the binary number as shown in the example above.

To calculate the number of bits required to represent a decimal number, take the binary logarithm of the decimal number and round the number up. For example, the number of bits required to represent 5353 is equal to log253=6\lceil{log_{2}{53}}\rceil = 6 bits.

Binary to decimal converter.

The following is an interactive tool in which you can click on any bit to flip its state. The tool will show you the decimal equivalent of the corresponding binary number.

Binary to Decimal Converter.

What is a byte?

An 8-bit binary number is known as a byte. Or, one byte consists of 88 bits.

1 byte = 8 bits

An example of a byte is shown in Figure 4. A byte has 256 different configurations which means that a byte can store 256 different numbers. The maximum value that one byte can store is 255, as shown in Figure 5, whereas the minimum value that it can store is 0.

If you want to store a number that is greater than 255, you can add more bytes. Two bytes can store 65536 different configurations, ranging from 00 to 65535.

Figure 4: A byte made up of 8 bits.
Figure 5: A byte representing the number 255.

Quiz on binary digits and bytes.

1

Convert 10210_{2} from binary to a decimal number and select the right option below:

A)

3

B)

10

C)

2

D)

20

Question 1 of 50 attempted