9010 Leson 1.3 INTRODUCTION TO BINARY NUMBER

Email: info@saypro.online Call/WhatsApp: + 27 84 313 7407

SayPro is a Global Solutions Provider working with Individuals, Governments, Corporate Businesses, Municipalities, International Institutions. SayPro works across various Industries, Sectors providing wide range of solutions.

To understand binary numbers, begin by recalling elementary school math. When we first learned about numbers, we were taught that, in the decimal system, things are organized into columns:

    H | T | O

    1 | 9 | 3

Such that “H” is the hundreds column, “T” is the tens column, and “O” is the ones column. So the number “193” is 1-hundreds plus 9-tens plus 3-ones.

Years later, we learned that the ones column meant 10^0, the tens column meant 10^1, the hundreds column 10^2 and so on, such that

      10^ 2 |10^1|10^0

        1 | 9 |  3  

   the number 193 is really {(1*10^2)+(9*10^1)+(3*10^0)}.

As you know, the decimal system uses the digits 0-9 to represent numbers. If we wanted to put a larger number in column 10^n (e.g.,10), we would have to multiply10*10^n, which would give       10^(n+1), and be carried a column to the left. For example, putting ten in the 10^0 column is impossible, so we put a 1 in the 10^1 column, and a 0 in the 10^0 column, thus using two columns. Twelve would be 12*10^0, or 10^0(10+2), or 10^1+2*10^0, which also uses an additional column to the left (12).

The binary system works under the exact same principles as the decimal system, only it operates in base 2 rather than base 10. In other words, instead of columns being

       10^2|10^1|10^0

they are

        2^2|21|2^0

Instead of using the digits 0-9, we only use 0-1 (again, if we used anything larger it would be like multiplying 2*2^n and getting 2^n+1, which would not fit in the 2^n column. Therefore, it would shift you one column to the left. For example, “3” in binary cannot be put into one column. The first column we fill is the right-most column, which is 2^0, or 1. Since 3>1, we need to use an extra column to the left, and indicate it as “11” in binary (1*2^1) + (1*2^0).

The binary system can be defined as the numeration system based on powers of 2, in contrast to the familiar decimal system, which is based on powers of 10.Thus, the first ten numbers in binary notation, corresponding to the numbers 0,1,2,3,4,5,6,7,8, and 9 in decimal notation, are 0,1,10,11,100,101,110,111,1000, and 1001.

Binary numbers are sometimes written with a subscript “b” or “2” (eg.11101.012) to distinguish them from decimal numbers having the same digits. As with the decimal system, fractions can be represented by digits to the right of the binary point (analogous to the decimal point).

 A binary number is generally much longer than the decimal equivalent; e.g., the number above, 1011010b, contains seven digits while its decimal counterpart, 90, contains only two. This is a disadvantage for most ordinary applications but is offset by the greater simplicity of the binary system in computer applications. Since only two digits are used, any binary digit, or bit, can be transmitted and recorded electronically simply by the presence or absence of an electrical pulse or current. The great speed of such devices more than compensates for the fact that a given number may contain a large number of digits.

 

1.2 CONVERSION BETWEEN BINARY AND DECIMAL NUMBERS

The base of any number system is determined by the number of digits in the system. For example, we know that binary is a base-2 number system since it uses two digits and decimal is a base-10 system since it uses ten digits.

As mentioned before, we will also distinguish between various number systems by putting a small subscript after the number to indicate the base.

For example, a typical decimal number would be written like 46210 (note, normally the subscript is not used) and a typical binary number would be written like 1102.

1.2.1 Decimal to binary conversion

 To convert from decimal to binary we use repeated division on the integer part. Take the decimal number 111.

The steps below show how to convert the number 1110 number to binary using repeated division. The ‘R’ stands for the remainder of the division.

First, we divide 11 by 2 to find the least significant digit (the rightmost digit). Since 1 is our remainder, the least significant digit in our answer is 1.

11 / 2 = 5 R 1

Answer:

? ? ? 1

Next, we take the result of the previous division (5) and divide by 2 again. Since 5 divided by 2 leaves a remainder of 1, the next digit of our answer is 1.

5 / 2 = 2 R 1

Answer:

? ? 1 1

Again we take the result of the previous division (2) and divide by 2. This time our division does not have a remainder, so we write a 0 as the next digit of our answer.

2 / 2 = 1 R 0

Answer:

? 0 1 1

One more division by 2 gives us the most significant digit (the leftmost digit) of our answer. Since 2 will not divide 1, our result is 0 with a remainder of 1. We know we are done when we get 0 as the result of our division.

1 / 2 = 0 R 1

Answer:

1 0 1 1

A good way to organise this conversion is to list the divisions in table form as below.

11 / 2 = 5 R of 1 (rightmost digit)

5 / 2 = 2 R of 1

2 / 2 = 1 R of 0

1 / 2 = 0 R of 1 (leftmost digit)

Reading from bottom to top, the final answer is 10112. Remember that the first division gives us the least significant digit of our answer, and the final division gives us the most significant digit of our answer. Also, the result of the final division is always 0.

1.2.2 Binary to decimal conversion

However, this is not the only approach possible. We can start at the right, rather than the left.

All binary numbers are in the form

a[n]*2^n + a[n-1]*2^(n-1)+…+a[1]*2^1 + a[0]*2^0

Where each a[i] is either a 1 or a 0 (the only possible digits for the binary system). The only way a number can be odd is if it has a 1 in the 2^0 columns, because all powers of two greater than 0 are even numbers (2, 4, 8, 16…). This gives us the rightmost digit as a starting point.

Now we need to do the remaining digits. One idea is to “shift” them. It is also easy to see that multiplying and dividing by 2 shifts everything by one column: two in binary is 10, or (1*2^1). Dividing (1*2^1) by 2 gives us (1*2^0), or just a 1 in binary. Similarly, multiplying by 2 shifts in the other direction: (1*2^1)*2=(1*2^2) or 10 in binary. Therefore

{a[n]*2^n + a[n-1]*2^(n-1) + … + a[1]*2^1 + a[0]*2^0}/2

is equal to  a[n]*2^(n-1) + a[n-1]*2^(n-2) + … + a[1]2^0

Let’s look at how this can help us convert from decimal to binary. Take the number 163. We know that since it is odd, there must be a 1 in the 2^0 column (a[0]=1). We also know that it equals 162+1. If we put the 1 in the 2^0 column, we have 162 left, and have to decide how to translate the remaining digits.

Two’s column: Dividing 162 by 2 gives 81. The number 81 in binary would also have a 1 in the 2^0 column. Since we divided the number by two, we “took out” one power of two. Similarly, the statement a[n-1]*2^(n-1) + a[n-2]*2^(n-2) + … + a[1]*2^0 has a power of two removed. Our “new” 2^0 column now contains a1. We learned earlier that there is a 1 in the 2^0 column if the number is odd. Since 81 is odd, a[1]=1. Practically, we can simply keep a “running total”, which now stands at 11 (a[1]=1 and a[0]=1). Also note that a1 is essentially “re-multiplied” by two just by putting it in front of a[0], so it is automatically fit into the correct column.

Four’s column: Now we can subtract 1 from 81 to see what remainder we still must place (80). Dividing 80 by 2 gives 40 therefore, there must be a 0 in the 4’s column, (because what we are actually placing is a 2^0 column, and the number is not odd).

Eight’s column: We can divide by two again to get 20. This is even, so we put a 0 in the 8’s column. Our running total now stands at a[3]=0, a[2]=0, a[1]=1, and a[0]=1.

We can continue in this manner until there is no remainder to place.

  Let’s formalize this algorithm:1.  Let D= the number we wish to convert from decimal to binary.2.  Repeat until D=0:    a) If D is odd, put “1” in the leftmost open column, and subtract 1 from D.    b) If D is even, put “0” in the leftmost open column.    c) Divide D by 2.    End RepeatFor the number 163, this works as follows:1.  Let D=163Step 2 b) D is odd, put a 1 in the 2^0 column.  Subtract 1 from D to get 162.          c) Divide D=162 by 2.Temporary Result: 01     New D=81D does not equal 0, so we repeat step 2.                                                               Step 2 b) D is odd, put a 1 in the 2^1 column.  Subtract 1 from D to get 80.            c) Divide D=80 by 2.Temporary Result: 11     New D=40D does not equal 0, so we repeat step 2.Step 2 b) D is even, put a 0 in the 2^2 column.            c) Divide D by 2.Temporary Result: 011    New D=20Step 2 b) D is even, put a 0 in the 2^3 column.             c) Divide D by 2.Temporary Result: 0011     New D=10Step 2 b) D is even, put a 0 in the 2^4 column.            c) Divide D by 2.Temporary Result:  00011      New D=5Step 2 a) D is odd, put a 1 in the 2^5 column.       Subtract 1 from D to get 4.            c) Divide D by 2. Temporary Result:  100011   New D=2Step 2 b) D is even, put a 0 in the 2^6 column.            c) Divide D by 2.Temporary Result:  0100011   New D=1Step 2a) D is odd, put a 1 in the 27 column.       Subtract 1 from D to get D=0.          c) Divide D by 2.Temporary Result:  10100011   New D=0D=0, so we are done, and the decimal number 163 is equivalent to the binary number 10100011.

Since we already knew how to convert from binary to decimal, we can easily verify our result. 10100011=(1*2^0)+(1*2^1)+(1*2^5)+(1*2^7)=1+2+32+128= 163.

Examples

      i.        Try converting these numbers from binary to decimal:

  • 10
  • 111
  • 10101
  • 11110

Answer

  • 10=(1*2^1) + (0*2^0) = 2+0 = 2
  • 111 = (1*2^2) + (1*2^1) + (1*2^0) = 4+2+1=7
  • 10101= (1*2^4) + (0*2^3) + (1*2^2) + (0*2^1) + (1*2^0)=16+0+4+0+1=21
  • 11110= (1*2^4) + (1*2^3) + (1*2^2) + (1*2^1) + (0*2^0)=16+8+4+2+0=30

     ii.        What would the binary number 1011 be in decimal notation?

Answer

   1011= (1*2^3)+(0*2^2)+(1*2^1)+(1*2^0)

       = (1*8) + (0*4) + (1*2) + (1*1)

       = 11 (in decimal notation)

 

1.2.3 Decimal vs. Binary

Here are some equivalent values:

Decimal:

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Binary:

0

1

10

11

100

101

110

111

1000

1001

1010

1011

1100

1101

1110

1111

Here are some larger equivalent values:

Decimal:

20

25

30

40

50

100

200

500

Binary:

10100

11001

11110

101000

110010

1100100

11001000

111110100

“Binary is as easy as 1, 10, 11.”

Position

In the Decimal System there are the Units, Tens, Hundreds, etc

            In Binary, there are Units, Twos, Fours, etc, like this:

This is 1×8 + 1×4 + 0×2 + 1 + 1×(1/2) + 0×(1/4) + 1×(1/8) = 13.625 in Decimal

Numbers can be placed to the left or right of the point, to indicate values greater than one or less than one.

10.1

The number to the left of the point is a whole number (10 for example) As we move further left, every number place gets 2 times bigger. The first digit on the right means halves (1/2). As we move further right, every number place gets 2 times smaller (half as big).

Using: 10.1

  • The “10” means 2 in decimal,
  • The “.1” means half,
  • So “10.1” in binary is 2.5 in decimal

The word binary comes from “Bi-” meaning two. We see “bi-” in words such as “bicycle” (two wheels) or “binocular” (two eyes). When you say a binary number, pronounce each digit (example, the binary number “101” is spoken as “one zero one”, or sometimes “one-oh-one”).This way people don’t get confused with the decimal number. A single binary digit (like “0” or “1”) is called a “bit”. For example 11010 is five bits long. The word bit is made up from the words “binary digit

 

Exercise

Introduction to the binary number system

1. We mean the following when we use the term “binary number system”:

2. The decimal system is based on powers of (the base to the power of):

3. In the binary system, only the digits ________ and _______ are used.

4. Write three even numbers (between zero and ten) in binary notation and give the

decimal equivalent.

5. Write in binary notation the five first uneven numbers

6. The number 453 means (indicate what each position means – multiplied by 10 to the

power of the position)

7. As with the decimal system, fractions can be represented by digits to the right of the

______________(analogous to the decimal point).

8. A binary number is generally much longer than the decimal equivalent; e.g., 1011010b,

contains seven digits while its _____________________ counterpart which is

________________ contains only two.

 

 

  • Neftaly Malatjie | CEO | SayPro
  • Email: info@saypro.online
  • Call: + 27 84 313 7407
  • Website: www.saypro.online

SayPro ShopApp Jobs Courses Classified AgriSchool Health EventsCorporate CharityNPOStaffSports

Comments

Leave a Reply