Binary (#1)

Everything about computers on the software level, programming level, etc., stems from this word. Binary means 0 and 1. It means whether the electrical signal is present or absent. In classical computers, these are the only two possibilities from which the entire digital world of information and computation emerges. Whenever you see a .bin file in your computer or elsewhere, remember that it is the file which contains only 1’s and 0’s.

Bits: These are the basic building blocks of this digital world. Generally, and not universally, 0 means the output is “electrical low voltage” (0V), and 1 means the output is “electrical high voltage” (e.g., 5V). In mathematical logic, 0 (or F) means False, and 1 (or T) means True. Usually, the binary numbers are written as  {(0111110000100101010)}_2 . We will now see how to convert binary to decimal numbers and vice versa. (Note: Every bit can take either 0 or 1 as values.)

Before we proceed to the examples, we first need to know the manner in which the data is stored:
$$ \text{8 bits = 1 byte or 1B} \newline \text{1024 bits = 1 kibibits or 1Kib} \newline \text{1024 bytes = 1 kibibyte or 1 KiB} \newline \text{1024 kibibytes = 1 mebibyte or 1 MiB} \newline \text{1024 mebibytes = 1 gibibyte or 1 GiB} \newline \text{1024 gibibytes = 1 tebibyte or 1 TiB} $$ and so on. The ‘bi’ in each word is for binary, since the Hard drive manufacturers use the decimal system while other people use the binary system to calculate the values, hence the distinction.

$$ \text{1000 bits = 1 kilobits or 1Kb} \newline \text{1000 bytes = 1 kilobyte or 1 KB} \newline \text{1000 kilobytes = 1 megabyte or 1 MB} \newline \text{1000 megabytes = 1 gigabyte or 1 GB} \newline \text{1000 gigabytes = 1 terabyte or 1 TB} $$
We can expand this further by calculating values for petabytes, exabytes, yottabytes, etc. Notice that for bits, ‘b’ is written, and for bytes, ‘B’ is written. Therefore, 1 MB is NOT EQUAL TO 1 Mb. Because 1 byte is equal to 8 bits. Hence, 1 MB (1 million bytes) is equal to 8 Mb (8 million bits). And 500 GB is not equal to 500 GiB.

In the International System of Units (SI), symbols for prefixes larger than “kilo” (meaning thousands) are capitalized to distinguish them:
M (Mega) = Million
G (Giga) = Billion
T (Tera) = Trillion

Now, we will see how to convert binary numbers into decimal numbers (the numbers that we use on a regular basis):

Example 1.1: Convert  {(11100011)}_2 into a decimal number.
$$ \text{1. First of all, notice that the number is written with the base as 2 (subscript),} \newline \text{denoting that the number in the problem is written in the binary number system.} $$
$$ \text{2. The numbers can be written in various ways with their base as 10, 16, 8, etc.} \newline \text{We can write numbers in any number as a base, but base 2 (binary),} \newline \text{base 8 (octal), base 10 (decimal), and base 16 (hexadecimal)} \newline \text{are the ones most widely used in the computing world.} $$
$$ \text{3. Coming back to our problem, we can see that there are total} \newline \text{8 digits in the binary number 11100011.} $$
$$ \text{4. Then we have to start from the right most digit,} \newline \text{and then assign each digit a position number, starting from 0 (not 1).} $$
$$ \text{5. Before proceeding to calculate, make sure that you are familiar with the power tower of 2.} $$
$$ \text{6. Let us calculate the number as follows: } \text{From right to left} \newline {(1 \times {2^0})+(1 \times {2^1})+(0 \times {2^2})+(0 \times {2^3})+(0 \times {2^4})+(1 \times {2^5})+(1 \times {2^6})+(1 \times {2^7})} \newline {= (1\times1)+(1\times2)+(0)+(0)+(0)+(1\times{32})+(1\times{64})+(1\times128)} \newline {= 1+2+0+0+0+32+64+128} \newline {= 35+64+128} \newline {= 99+128} \newline {= 227} \newline \text{Therefore, $(11100011)_2$ = $(227)_{10}$} $$

Example 1.2: Convert  {(1011)}_2 into a decimal number.
$$ \text{1. We can see that there are total} \newline \text{4 digits in the binary number 1011.} $$
$$ \text{2. Then we have to start from the right most digit,} \newline \text{and then assign each digit a position number, starting from 0 (not 1).} $$
$$ \text{3. Let us calculate the number as follows: } \text{From right to left} \newline {(1 \times {2^0})+(1 \times {2^1})+(0 \times {2^2})+(1 \times {2^3})} \newline {= (1\times1)+(1\times2)+(0)+(1\times{8})} \newline {= 1+2+0+8} \newline {= 11} \newline \text{Therefore, $(1011)_2$ = $(11)_{10}$} $$

Example 1.3: Convert  {(101011)}_2 into a decimal number.
$$ \text{1. We can see that there are a total of} \newline \text{6 digits in the binary number 101011.} $$
$$ \text{2. Then we have to start from the rightmost digit, } \newline \text{and then assign each digit a position number, starting from 0 (not 1).} $$
$$ \text{3. Let us calculate the number as follows: } \text{From right to left} \newline {(1 \times {2^0})+(1 \times {2^1})+(0 \times {2^2})+(1 \times {2^3})+(0 \times {2^4})+(1 \times {2^5})} \newline {= (1\times1)+(1\times2)+(0)+(1\times{8})+(0)+(1 \times 32)} \newline {= 1+2+0+8+0+32} \newline {= 43} \newline \text{Therefore, $(101011)_2$ = $(43)_{10}$} $$

Now, let’s learn the reverse process, i.e., how to convert decimal numbers into binary numbers.

Example 2.1 Convert  {(55)}_{10} into a binary number.
Here is the step-by-step process:

  1. Divide 55 by 2.
  2. Record the remainder (it will always be either 0 or 1).
  3. Take the quotient (the result of the division) and divide it by 2 again.
  4. Repeat until the quotient reaches 0.
StepDivisionQuotientRemainder
155 ÷ 2271
227 ÷ 2131
313 ÷ 261
46 ÷ 230
53 ÷ 211
61 ÷ 201

Now, read the remainders from the bottom to the top (from the last remainder to the first).
Bottom to top: 1 1 0 1 1 1

Example 2.2 Convert  {(97)}_{10} into a binary number.

  1. Divide 97 by 2.
  2. Record the remainder (it will always be either 0 or 1).
  3. Take the quotient (the result of the division) and divide it by 2 again.
  4. Repeat until the quotient reaches 0.
StepDivisionQuotientRemainder
197 ÷ 2481
248 ÷ 2240
324 ÷ 2120
412 ÷ 260
56 ÷ 230
63 ÷ 211
71 ÷ 201

Now, read the remainders from the bottom to the top (from the last remainder to the first).
Bottom to top: 1 1 0 0 0 0 1
You can verify it by converting the number again to binary.

Here it is. The basic process is to understand the basic building block of the digital world. Practice it, and you can begin to understand its advanced techniques, such as how to proceed with the addition and subtraction of two binary numbers and how to address specific bits and apply the logic gate operations to them. Keep learning, stay curious, and All the Best!


Discover more from universeunlocks.in

Subscribe to get the latest posts sent to your email.

Leave a Reply