CHAPTER 01.04: BINARY REPRESENTATION : Base-10 to Base-2 Conversion Method
Okay, in this segment weíre going to talk about how to convert a base-10 to base-2, a number from base-10 to base-2. So Iím going to show you through example, Iím not going to give you the proof for it. It can be proven, the method which Iím going to show you, youíll be able to show by proof why this works to convert a base-10 number to a base-2 number, but the only thing which Iím going to concentrate on in this segment is the method itself, how to convert a base-10 number to base-2 number. So for example, Iím going to take the same number, 11.1875, which I had previously, and this is in base-10. How do I convert this number into base-2? What is the base-2 equivalent? So this is the question mark right here, radix point, another question mark, base-2. If Iíve got to find out what should I fill in for this question mark, and what should I fill in for this question mark.
So letís go ahead and start with the integer part, which is the part before the decimal point in this case, or what we call the radix point for any base. So letís go ahead and see what the equivalent of 11 is. So Iím going to draw a table here, thatís the best way to go ahead and convert these numbers in decimal notation. So Iím going to say, hey, Iím going to put the quotient here, and Iím going to put the remainder here, and Iíll tell you what that means. So Iím going to take this number 11, and what Iím going to do is, Iím going to divide this by 2, and the reason why Iím dividing by 2 is thatís what base. So Iím going to take the 11 number, divide it by 2, what do I get as the quotient? I get quotient is 5, and what is the remainder? The remainder is 1. Now I take the quotient which I just got, which was 5, thatís this number right here, I divide that by 2, and I get 2 as my quotient and again 1 as the remainder. Now I take the number 2 and I again divide it by 2, so youíre dividing by the same number here, the quotient is 1, and the remainder is 0, of course. Now Iím left with a quotient of 1, I get 1 divided by 2. If I do 1 divided by 2, I get a quotient of 0, and a remainder of 1. And thatís where I stop, as soon as the quotient becomes 0, when Iím looking at the integer part, I stop the whole process. Now, what I will have is that this one is a0, this one is a1, this one is, I call a2, and this one I call a3, so this is the remainder which I get in the first step, second step, third step, fourth step. So the equivalent of 11 in the base-2 will be equal to a3, a2, a1, and a0, so the equivalent will be 1011 base-2. So you do need to look at it this way, that if you are not going to do it this way where you are going to signify a0, a1, a2, and a3, what youíve got to understand is that the first number which goes here is the last number which you calculated, and the next number which should go there is the second-to-last number which you calculated, and so on and so forth, so youíre going backwards. So the equivalent of 11, this should be base-10, thatís wrong, so the equivalent of the number of 11 in the base-10 is 1, which is this 1, then 0, which is this 0, then this 1, which is this 1, and then this 1 is right here, so you go backwards to look at the equivalent number.
Now if youíre going to go ahead and try to find out what the decimal equivalent, or base-10 equivalent, of this number is, youíre going to exactly get 11 from there, so I will leave that as an exercise for you to do. Now letís go ahead and look at the fractional part, which is 0.1875, how do we go about finding the equivalent of that? So Iíve got 0.1875, which is in base-10, and Iíve got to find out what is it in base-2, so thatís the rest of the number here. So in this case, what you do is, rather than dividing by 2, you multiply by 2. So let me draw a table here, thatís the best way to do these problems when you are a beginner. So Iím going to get 0.1875, thatís the number which I have, and I will multiply by 2, and I get 0.375. So thatís the number which I am getting, and then what Iíve got to look at is the number after the decimal point, and then Iíve got to also look at the number before the decimal point. So when I multiply 0.1875 by 2 I get 0.375, the number after the decimal point is still 0.375, the number before the decimal point is just 0. So thatís how Iíve got to extract it, so Iíve got to extract the integer part of this number and the fractional part of this number, so the fractional part of the number is still 0.375, and the number before the decimal point is 0. Now I take 0.375 and I multiply by 2, I get 0.750. So in this case again here, the number which is after the decimal point is 0.750, the number before the decimal point is still 0. Now I go ahead and take, again, I get 0.75 now, multiply by 2, now I get 1.50. So you might have been wondering, why are those numbers 0 before the decimal point, and thatís the way it turned out to be. Now 0.75 multiplied by 2 is 1.50, so the number after the decimal point is 0.500, and the number before the decimal point is 1. Now Iím left with 0.5, which is the number after the decimal point, those are the numbers which I have put in here, so I get 0.5 times 2, I get 1.00. The number after the decimal point is 0.00, and the number before the decimal point is simply 1. And thatís when I stop, when I find out that the number which is left after the decimal point is simply 0, thatís when you stop the whole process, that you donít need to do it any further, that you have obtained what the equivalent binary number is for that. And now what Iím going to do is Iím going to call this to be a(-1), Iím going to call this to be a(-2), Iím going to call this to be a(-3), and this to be a(-4). So the equivalent of 0.1875 base-10 is equal to a(-1), a(-2), a(-3), a(-4) base-2, which in this case would be 0, thereís a radix point right here, radix point here, 0011 base-2. So in this case, when you are writing down the equivalent of the fractional part, you start from the top, you get 0, 0, 1, 1 Ė 0011, as opposed to when you were doing the integer part, you started from the bottom, but here you start from the top, 0, 0, 1, 1 Ė 0011. So if you look at the overall number, which is 11.1875 base-10, then the whole equivalency in the binary notation will be whatever is the equivalent of 11, which turned out to be 1011, so thatís what we found on the previous part of this segment, so we got 1011 as the equivalent of 11, and for 0.1875, we just calculated is the radix point right here, 0011 base-2. So as an exercise, what you need is go ahead and see whether you can go from here to here, and be sure that you calculate this to be equal to 11.1875 in base-10. And thatís the end of this segment.