1 00:00:00,060 --> 00:00:01,380 Computers do their numbering 2 00:00:01,380 --> 00:00:04,050 and do math a little bit differently than we do. 3 00:00:04,050 --> 00:00:05,430 Now, as a kid, you learned 4 00:00:05,430 --> 00:00:07,500 to count in what's known as base 10. 5 00:00:07,500 --> 00:00:10,560 This is a decimal number, right? Decimal meaning 10. 6 00:00:10,560 --> 00:00:13,290 And so when I count, you would start at zero 7 00:00:13,290 --> 00:00:17,310 and you go 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. 8 00:00:17,310 --> 00:00:18,990 Now, what comes next? 9 00:00:18,990 --> 00:00:20,100 Well, we go to the second column, 10 00:00:20,100 --> 00:00:22,170 we put a one there and we go back to zero. 11 00:00:22,170 --> 00:00:25,770 So now we go from nine to 10, and then we keep counting up 12 00:00:25,770 --> 00:00:28,181 and eventually, we get to 98, 99, 13 00:00:28,181 --> 00:00:30,000 and then we go, ah, I need another column. 14 00:00:30,000 --> 00:00:33,060 Put another one there and add two zeros. That's 100. 15 00:00:33,060 --> 00:00:35,370 So go 98, 99, 100, right? 16 00:00:35,370 --> 00:00:36,570 And that's the whole idea here 17 00:00:36,570 --> 00:00:37,983 when we talk about decimal, right? 18 00:00:37,983 --> 00:00:39,210 When we talk about decimal, 19 00:00:39,210 --> 00:00:41,400 we only have 10 choices for the numbers. 20 00:00:41,400 --> 00:00:46,200 Each decimal place can only be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. 21 00:00:46,200 --> 00:00:47,820 Those are our 10 options. 22 00:00:47,820 --> 00:00:48,990 Now, computers and networks 23 00:00:48,990 --> 00:00:51,240 don't actually understand decimal natively. 24 00:00:51,240 --> 00:00:52,980 So even though we've been using decimal when talking 25 00:00:52,980 --> 00:00:56,580 about IPv4 addresses, that's not how computers see them. 26 00:00:56,580 --> 00:00:58,470 Computers do everything in binary, 27 00:00:58,470 --> 00:01:00,150 which is base two numbering. 28 00:01:00,150 --> 00:01:01,980 That means every single digit 29 00:01:01,980 --> 00:01:04,290 is either a one or it's a zero. 30 00:01:04,290 --> 00:01:06,480 That's an on or it's an off. 31 00:01:06,480 --> 00:01:08,700 That is how computers understand things. 32 00:01:08,700 --> 00:01:10,260 And so when they count, they go, 33 00:01:10,260 --> 00:01:15,260 0, 1, 10, 11, 100, 111. 34 00:01:15,630 --> 00:01:17,370 And they keep going like that. 35 00:01:17,370 --> 00:01:20,010 The 10 is actually the number two for us, 36 00:01:20,010 --> 00:01:24,300 but for them in binary, that is actually a 10. 37 00:01:24,300 --> 00:01:26,040 And 10 equates to two 38 00:01:26,040 --> 00:01:27,660 because it's the third thing we got to. 39 00:01:27,660 --> 00:01:29,400 0, 1, 2. 40 00:01:29,400 --> 00:01:31,320 Now, that's the way this works with a computer. 41 00:01:31,320 --> 00:01:32,822 And so we have to understand 42 00:01:32,822 --> 00:01:34,620 how things are written in decimal 43 00:01:34,620 --> 00:01:36,210 and how things are written in binary 44 00:01:36,210 --> 00:01:38,310 and how to convert between the two. 45 00:01:38,310 --> 00:01:39,510 And that's what we're going to talk about 46 00:01:39,510 --> 00:01:41,340 in this particular lesson. 47 00:01:41,340 --> 00:01:43,950 Now, when we convert from binary to decimal, 48 00:01:43,950 --> 00:01:45,600 we're going to do this using a table 49 00:01:45,600 --> 00:01:47,250 that I have here on the screen. 50 00:01:47,250 --> 00:01:49,530 Each number is a factor of two. 51 00:01:49,530 --> 00:01:51,360 And so this way, we can start going 52 00:01:51,360 --> 00:01:53,700 and putting them as placeholders of one or zero 53 00:01:53,700 --> 00:01:55,620 as we go through each place. 54 00:01:55,620 --> 00:01:59,490 So if we start on the right and we go left, we have one, 55 00:01:59,490 --> 00:02:02,310 and then we have a place of one, right? 56 00:02:02,310 --> 00:02:04,590 Now, if I put a one, zero in the second 57 00:02:04,590 --> 00:02:08,009 and first columns, this is going to become two. 58 00:02:08,009 --> 00:02:10,440 And we keep going through as we keep counting. 59 00:02:10,440 --> 00:02:12,030 Now, if you're not getting it quite yet, 60 00:02:12,030 --> 00:02:14,010 you will by the end of this lesson, I promise. 61 00:02:14,010 --> 00:02:15,240 So let's just keep going ahead 62 00:02:15,240 --> 00:02:17,310 and we're going to do some examples together. 63 00:02:17,310 --> 00:02:20,050 Let's say I give you the binary number of 10010110 64 00:02:22,740 --> 00:02:24,900 and I asked you to tell me what is this 65 00:02:24,900 --> 00:02:26,610 if I put it into decimal? 66 00:02:26,610 --> 00:02:28,860 Well, we're going to first by populating the table, 67 00:02:28,860 --> 00:02:31,410 starting from the right and going to the left. 68 00:02:31,410 --> 00:02:33,090 And so we're going to put the number there 69 00:02:33,090 --> 00:02:34,290 that we have from right to left 70 00:02:34,290 --> 00:02:36,330 and end up with what you see here on the screen. 71 00:02:36,330 --> 00:02:40,830 It turns into 1001011 and 0. 72 00:02:40,830 --> 00:02:42,810 Now, there's a place where there's a one, 73 00:02:42,810 --> 00:02:44,550 and I'm going to add the number above it. 74 00:02:44,550 --> 00:02:49,550 So if I see something like 128 plus 16 plus 4 plus 2, 75 00:02:50,610 --> 00:02:54,300 and I add that all together, I'm going to get 150. 76 00:02:54,300 --> 00:02:59,300 That is the number 10010110 in binary, 77 00:02:59,490 --> 00:03:02,220 and it translates to 150 in decimal. 78 00:03:02,220 --> 00:03:04,650 You see how easy that is if you have the little chart? 79 00:03:04,650 --> 00:03:07,320 So if you make this chart on your paper when you sit down 80 00:03:07,320 --> 00:03:10,290 for the exam, it's going to make things a lot easier for you. 81 00:03:10,290 --> 00:03:12,330 Again, going from right to left on the chart, 82 00:03:12,330 --> 00:03:15,240 each position starts out with the number 83 00:03:15,240 --> 00:03:19,450 of 1, 2, 4, 8, 16, 32, 64, 128. 84 00:03:20,820 --> 00:03:23,940 We keep multiplying by two as we go from right to left. 85 00:03:23,940 --> 00:03:25,830 And so if I added up every single one of those 86 00:03:25,830 --> 00:03:26,663 with a one in it, 87 00:03:26,663 --> 00:03:28,770 guess what the biggest number I could get is. 88 00:03:28,770 --> 00:03:32,760 255, which if you remember when I talked about IPv4, 89 00:03:32,760 --> 00:03:36,840 all my numbers were either zero all the way up through 255. 90 00:03:36,840 --> 00:03:38,310 That's my four octets. 91 00:03:38,310 --> 00:03:40,500 Well, that's because I have eight digits in each 92 00:03:40,500 --> 00:03:41,910 of those octets, right? 93 00:03:41,910 --> 00:03:43,860 And each digit, each binary digit 94 00:03:43,860 --> 00:03:45,720 can only hold a one or a zero. 95 00:03:45,720 --> 00:03:47,610 Now, what if I gave you a decimal number, 96 00:03:47,610 --> 00:03:48,870 like from an IP address 97 00:03:48,870 --> 00:03:50,700 and asked you to convert that to binary? 98 00:03:50,700 --> 00:03:52,770 Could you do it? Well, the answer is yes. 99 00:03:52,770 --> 00:03:55,470 It's the exact same process we just did. 100 00:03:55,470 --> 00:03:57,630 So let's take a number from 167 101 00:03:57,630 --> 00:03:59,820 and convert it backwards to binary. 102 00:03:59,820 --> 00:04:01,350 That'd be one of the octets inside 103 00:04:01,350 --> 00:04:02,970 of an IP address, for instance. 104 00:04:02,970 --> 00:04:05,820 Well, instead of adding up, we're going to be subtracting. 105 00:04:05,820 --> 00:04:07,920 So when I do this, I'll take 167 106 00:04:07,920 --> 00:04:09,480 and I'll start from the left. 107 00:04:09,480 --> 00:04:13,290 Can I take 128 out of 167? Yes, I can. 108 00:04:13,290 --> 00:04:16,440 And I'll have 39 leftover. Then I go to the next column. 109 00:04:16,440 --> 00:04:19,769 That's 64. Can I take 64 from 39? 110 00:04:19,769 --> 00:04:21,570 No, because there's not enough there. 111 00:04:21,570 --> 00:04:24,030 So I'll put a zero under the 64 column. 112 00:04:24,030 --> 00:04:26,490 Then I'll say, can I take 32 out of 39? 113 00:04:26,490 --> 00:04:28,950 Yes, I can, and I'll have seven leftover. 114 00:04:28,950 --> 00:04:30,600 So I'll put one in that column. 115 00:04:30,600 --> 00:04:34,350 Then I look, can I take 16 from seven? No, so I put a zero. 116 00:04:34,350 --> 00:04:37,320 How about eight from seven? No, so I put a zero. 117 00:04:37,320 --> 00:04:38,640 How about four from seven? 118 00:04:38,640 --> 00:04:40,680 Yes, and that leads me with three. 119 00:04:40,680 --> 00:04:42,540 Can I go ahead and take two from three? 120 00:04:42,540 --> 00:04:44,640 Yes, I'll put a one in that column. 121 00:04:44,640 --> 00:04:46,110 And then can I take one from one? 122 00:04:46,110 --> 00:04:48,270 Yes, and I'll put a one down for that. 123 00:04:48,270 --> 00:04:51,000 And this is how you convert from decimal back to binary. 124 00:04:51,000 --> 00:04:52,920 You're going to subtract on the way down. 125 00:04:52,920 --> 00:04:55,080 Just like what I went from binary to decimal, 126 00:04:55,080 --> 00:04:57,240 I added up, going from decimal to binary, 127 00:04:57,240 --> 00:04:59,010 I'm going to go ahead and subtract. 128 00:04:59,010 --> 00:05:02,010 Now, either way, if you have this chart down, these factors 129 00:05:02,010 --> 00:05:04,740 of two, it makes these problems very, very easy. 130 00:05:04,740 --> 00:05:06,600 So now that we have that example under way 131 00:05:06,600 --> 00:05:11,600 and we see that 167 is actually 10100111, 132 00:05:11,910 --> 00:05:14,490 how can I check my math and make sure I got it right? 133 00:05:14,490 --> 00:05:16,410 Well, I can go the other direction 134 00:05:16,410 --> 00:05:18,060 and I can add up the numbers, 135 00:05:18,060 --> 00:05:19,440 and if they all come back to 167, 136 00:05:19,440 --> 00:05:21,120 that means I did the problem correctly. 137 00:05:21,120 --> 00:05:22,680 So let's check our answer. 138 00:05:22,680 --> 00:05:26,340 128 plus 32 plus 4 plus 2 plus 1. 139 00:05:26,340 --> 00:05:28,020 That equals 167. 140 00:05:28,020 --> 00:05:30,270 That means we did our math problem correctly.