Converting Numbers to Binary (Base 10 to Base 2) - CCNA



I've been in school for just under a month and I am still getting new classes. Today's new class just so happened to be CCNA (Cisco Certified Network Associate Routing & Switching Certification), which naturally prepares us for the Cisco exam. This certificate is more so for those who intend on having a career in Systems Architecture rather than development, however everyone in my major takes it to help prepare us for any path we may consider.

In today's lesson, we took a lot of time on binaries, octals, and hexadecimals which are used in computers. It's basically the very fundamental way computers understand the information we give it. More specifically, how to change the base, and add numbers in the same base together. However, I am going to be dividing this up into different parts. Here, we will be looking at how

Binary
The numbers we commonly know are written in the base of 10: 1,2,3,4, etc. more or less due to the fact we have 10 fingers. Binary is similar except it is written in the base of 2. Most people know binary as a bunch of 1s and 0s and that is completely true, it is a bunch of 1s and 0s, but the combination of 1 and 0 is what makes it unique.

So, most people who don't know binary might go out searching for a table with all the possible numbers already converted into binary like 1(base 10) =1 (base 2), 2 (base 10) = 10 (base 2), and so on and so forth. But, I am not going to do that. you can very easily type that into Google and find a list like that instantaneously. I want to show you how to convert numbers that are in the base of 10 quickly and efficiently in the base of 2. There are two methods learned today: one in class and one at home, that will help you convert it.

Method 1:
For the first method, you can simply divide your way to the answer. To understand how to do this method you need a basic understanding of what modulo is, as what we are essentially using is modulo to get the binary number. Modulo to put it simply, is the division of two numbers, however instead of getting the answer to that division we get the remainder of the division. That is to say that if a number cannot be divided into a whole number, we are going to find the nearest number that can be divided by, and say the remainder (This can probably be better explained). For example, 20/ 2= 10, and the answer is a whole number so the remainder is 0, so 20 %2 = 0. However, if we took 21 and divided that by 2 we would get a number that contains decimals. Instead we would take a number less than 21 and go "Hey, 20 is divisible by 2 and the answer is an integer. Let's use that!", and we would use 20 and say that the remainder is 1. Hence 21%2=1.

Now that we have looked at what modulo is and more importantly a remainder, let's try the first method. For the base of two, it is pretty straight forward. Your remainder will always be a 1 or a 0. However, this method is also applied to base of 8 and base of 16, but we won't get into that right now. Let's say you have the number 20 in base of 10 and want to convert it into base of 2 or binary. You simply have to divide 20 by 2 as it is the base and calculate the remainder, then take the answer to the division and divide that by 2 until you can't anymore. Let me demonstrate:

20 divided by 2 is 10. Thus it has a remainder of 0. We then take 10 and divide that by 2 and find its remainder. 10 divided by 2 is 5 which leaves a remainder of 0, and we continue like that. 2 can go into 5 two times, which means it has a remainder of 1. 2/2=1 with a remainder of 0, and 1/2 is just 0 with a remainder of 1. To make this clearer, I added everything to a table:

Now using the remainders, you are able to get the binary number. Simply take the last division and work up. Thus 20 in base of 10 is equal to 10100 in base 2.

Method 2:
The second method, is one that learned at home and I believe to be much faster than the previous one where you divide and take the remainder... This one I promise you only takes a fraction of that time. So, first of all you are going to start off with a table like this, which can be slightly modified. 16 is not the biggest number, if anything you can add 32 before that, and 64 before 32. Essentially, doubling the first number to fit your needs. For this example, 16 is the biggest number we need.
Let's say that we once again want to find the number 20 in base of 10, once again in binary. Well, you simply have to look at which numbers add up to 20. In this case 16 and 4. So, above 16 and 4 you are going to place a 1, and in all the numbers you didn't use between the highest value you used (16 here) and 1, you are going to add a 0. Once you finished, you should start to realize that the order of the 1s and 0s look very familiar. That is because, it is the number we found using the other method 10100!



You see! That was pretty quick compared to the first method and you came to the correct result! Both of these methods can be applied to any number of the base 10 that you are trying to convert into base 2 or Binary. Next time, I will show you how to convert numbers into a base of 8 (Octal) and base of 16 (hexadecimal)!


Comments

Popular Posts