1 00:00:20,340 --> 00:00:24,685 In this video, we're going to look at the binary fractions 2 00:00:24,685 --> 00:00:29,030 again, but from a slightly different angle. I will show you 3 00:00:29,030 --> 00:00:32,585 an alternative method to convert decimal fractions into binary 4 00:00:32,585 --> 00:00:37,325 fractions, which will work in most cases. I will show you some 5 00:00:37,325 --> 00:00:41,275 examples, and again I will draw your attention to the 6 00:00:41,275 --> 00:00:42,855 limitations of this method. 7 00:00:43,580 --> 00:00:49,768 So let's look at an example. So what happens if you would need 8 00:00:49,768 --> 00:00:55,480 to convert 13.3125 into binary? From here on, I'm going to split 9 00:00:55,480 --> 00:01:00,716 the number I'm going to convert the whole number and the 10 00:01:00,716 --> 00:01:05,476 fraction part separately. The whole number 413. We're going to 11 00:01:05,476 --> 00:01:10,236 use the normal way of converting decimal numbers into binary's, 12 00:01:10,236 --> 00:01:13,092 so use the place where you 13 00:01:13,092 --> 00:01:20,649 table. 124 eight 16 So what combination of these makes up 13 14 00:01:20,649 --> 00:01:28,317 while 8 + 4 makes 12 + 1 makes 13, so the 15 00:01:28,317 --> 00:01:33,429 whole part of this decimal fraction is 1101. 16 00:01:34,500 --> 00:01:38,855 How about the decimal part? What I'm going to do now? I'm going 17 00:01:38,855 --> 00:01:41,535 to just separately right down the decimal part. 18 00:01:43,410 --> 00:01:48,846 And the trick is here to keep doubling the number. So what's 19 00:01:48,846 --> 00:01:51,111 the double of three 125? 20 00:01:51,840 --> 00:01:57,524 Double of five is 10, carried A1 double of two is 4 + 1 21 00:01:57,524 --> 00:02:03,614 makes 5 double of two is 2 and double of three is 6. Now what 22 00:02:03,614 --> 00:02:08,892 happened in here is that I do not have any overflow into the 23 00:02:08,892 --> 00:02:13,358 whole number part of this part of the structure and therefore 24 00:02:13,358 --> 00:02:17,012 I'm going to record 0 after the radix point. 25 00:02:18,320 --> 00:02:22,940 Then I'm going to keep doubling. Obviously double of 00, so I 26 00:02:22,940 --> 00:02:28,715 don't even need to think about that. 2 * 5 is 10, carried A one 27 00:02:28,715 --> 00:02:36,030 2 * 2 is 4 + 1 makes it five. 2 * 6 is 12. So record the two 28 00:02:36,030 --> 00:02:41,035 and the one is an overflow. So this digit. Now I'm going to 29 00:02:41,035 --> 00:02:44,885 pick up and record as the 2nd digit of the. 30 00:02:45,750 --> 00:02:46,940 Binary fraction. 31 00:02:48,620 --> 00:02:53,060 Imagine like if you were picking this one up from here recorded 32 00:02:53,060 --> 00:02:57,870 here. So from now it disappears. The next step that I'm going to 33 00:02:57,870 --> 00:03:02,310 do, I'm going to double again, but without the whole part. So 34 00:03:02,310 --> 00:03:04,160 I'm just going to 55. 35 00:03:05,080 --> 00:03:10,488 Which may extend double of two is 4 + 1 is 5 and there again I 36 00:03:10,488 --> 00:03:14,544 have got no overflow into the whole parts, so I'm going to 37 00:03:14,544 --> 00:03:15,896 record a 0 here. 38 00:03:17,150 --> 00:03:20,258 Double again 2 * 5 is 10. 39 00:03:22,330 --> 00:03:26,410 There is an overflow. This is my last digit here because from 40 00:03:26,410 --> 00:03:30,150 here on I've got no more fractional parts, so you stop 41 00:03:30,150 --> 00:03:34,570 when you end up with a zero in the fractional part. Now pulling 42 00:03:34,570 --> 00:03:35,590 the two together. 43 00:03:36,270 --> 00:03:43,398 13.3125, in decimal is the same 44 00:03:43,398 --> 00:03:50,526 as 1101 Radix .0101 in binary. 45 00:03:56,110 --> 00:04:02,518 The second example is 9.1875. Again separates the 46 00:04:02,518 --> 00:04:08,926 number into whole and fractional part. The whole 47 00:04:08,926 --> 00:04:11,329 part is 9. 48 00:04:12,300 --> 00:04:19,710 Which is 8 + 1, so eight no four, no two and one. 49 00:04:21,560 --> 00:04:23,148 The decimal part now. 50 00:04:23,690 --> 00:04:29,934 0.1875 Let's keep doubling it. 2 * 5 is 10 carry one. 2 * 51 00:04:29,934 --> 00:04:37,070 7 is 14 + 1 makes it 15 carried A one 2 * 8016 + 1 52 00:04:37,070 --> 00:04:44,206 is 17, carried A one. 2 * 1 is 2 + 1 is 3 again. I 53 00:04:44,206 --> 00:04:49,558 did not have any overflow into the whole number part, so the 54 00:04:49,558 --> 00:04:54,464 1st digit behind the radix point that I'm going to record. 55 00:04:54,500 --> 00:04:55,358 Is a 0. 56 00:04:56,590 --> 00:04:57,720 Double again. 57 00:04:58,790 --> 00:05:06,296 2 * 5 is 10, carried a warm 2 * 7 is 14 + 1 makes it 15. 58 00:05:06,296 --> 00:05:12,551 Carry the one 2 * 3 is 6 + 1, seven again no overflow into 59 00:05:12,551 --> 00:05:16,721 the whole part. So I'm going to record 0 here. 60 00:05:17,460 --> 00:05:24,225 Double again 2 * 5 is 10. Carried a wamp. 2 * 7 is 14 61 00:05:24,225 --> 00:05:30,088 + 1 makes it 15. Now I have gotten overflowing here, so I'm 62 00:05:30,088 --> 00:05:31,892 going to record this. 63 00:05:32,470 --> 00:05:36,551 As the next digit after the radix point and then double 64 00:05:36,551 --> 00:05:40,632 again, don't forget that this one is not here anymore because 65 00:05:40,632 --> 00:05:43,229 I picked up and recorded it in 66 00:05:43,229 --> 00:05:47,060 here. So 2 * 5 is 10. 67 00:05:47,900 --> 00:05:52,762 So the next digit is 1 again. So for the two things together. 68 00:05:53,650 --> 00:06:00,070 9.1875 in decimal is the same 69 00:06:00,070 --> 00:06:06,490 as 1001 radix .0011 in binary. 70 00:06:08,180 --> 00:06:12,761 The next number is 0.6875. Luckily, this number doesn't 71 00:06:12,761 --> 00:06:18,869 have any whole parts, so we just need to concentrate on the 72 00:06:18,869 --> 00:06:24,468 decimal fraction part so I can just simply keep doubling this 73 00:06:24,468 --> 00:06:31,594 number. 2 * 5 is 10. Carry one 2 * 7 is 14 + 74 00:06:31,594 --> 00:06:38,211 1 is 15, carried A one 2 * 8016 + 1 is 17. 75 00:06:38,250 --> 00:06:41,340 Either one 2 * 6 is. 76 00:06:41,970 --> 00:06:45,633 12 + 1 is 13, so I've got an 77 00:06:45,633 --> 00:06:49,490 overflow. So the 1st digit I'm going to record behind 78 00:06:49,490 --> 00:06:51,090 the radix point is 1. 79 00:06:54,730 --> 00:07:01,336 Double 2 * 5 is 10, carried A one 2 * 7 is 14 + 1 makes it 80 00:07:01,336 --> 00:07:07,575 15. Carry the one 2 * 3 is 6 + 1. Seven this case I did not 81 00:07:07,575 --> 00:07:12,346 have an overflow, so the next day did after the radix point is 82 00:07:12,346 --> 00:07:13,447 0 double again. 83 00:07:14,910 --> 00:07:22,798 2 * 510 carried A one 2 * 7 is 14 + 1 makes it 15 84 00:07:22,798 --> 00:07:28,714 overflow, so the next digit is 1. Remember that's gone now and 85 00:07:28,714 --> 00:07:36,109 O makes no difference there. 2 * 5 is 10, so it's 1.0. So we 86 00:07:36,109 --> 00:07:42,518 have got one more digit here, which is a one so 0.6875 in 87 00:07:42,518 --> 00:07:45,969 decimal. As the same is O radix 88 00:07:45,969 --> 00:07:47,510 .1011. In binary. 89 00:07:50,520 --> 00:07:55,260 Now let's look at a nice and easy decimal number. The one 90 00:07:55,260 --> 00:08:01,185 that we didn't quite know how to deal with at the end of the last 91 00:08:01,185 --> 00:08:05,925 video. So let's look at 3.4. So let's separate the number again 92 00:08:05,925 --> 00:08:11,060 in two whole and fractional parts, so three is 2 + 1, which 93 00:08:11,060 --> 00:08:16,590 is 1 one and the fractional part. Let's just double 2 * 4 is 94 00:08:16,590 --> 00:08:21,330 0.8, so after the radix point, the 1st digit will be 0. 95 00:08:21,620 --> 00:08:24,120 2 * 8 is 16. 96 00:08:24,660 --> 00:08:28,020 So 1.6 the next digit is 1. 97 00:08:29,560 --> 00:08:32,227 2 * 6 is 12, so 2. 98 00:08:32,740 --> 00:08:35,680 .1 again carry the one. 99 00:08:37,310 --> 00:08:44,534 Double of two is 4 no carry, 004 is 8 again, no 100 00:08:44,534 --> 00:08:51,156 overflow. Double F8 is 16 so I've got one here now. 101 00:08:52,120 --> 00:08:58,945 WF6 is 12. I've got another one here. Now double F2 is 4. 102 00:09:00,040 --> 00:09:05,804 Put down a zero and hold on. I'm repeating myself look. 103 00:09:06,750 --> 00:09:10,646 Point 4.8. 6248624862 104 00:09:10,646 --> 00:09:18,035 so this. Simple decimal fraction 3.4 is 105 00:09:18,035 --> 00:09:23,102 an infinitely recurring binary fraction, so that's again shows 106 00:09:23,102 --> 00:09:28,732 you some difficulties when it comes to converting that simple 107 00:09:28,732 --> 00:09:33,236 fractions to binary fractions. So this would be. 108 00:09:33,940 --> 00:09:40,420 3.4 in decimal would be 1 109 00:09:40,420 --> 00:09:43,660 one radix .01100110. 110 00:09:44,170 --> 00:09:47,970 212345678 places. 111 00:09:50,970 --> 00:09:55,782 As I mentioned it in the last video, this is something that's 112 00:09:55,782 --> 00:09:59,391 fundamentally inherent property of the binary number system. We 113 00:09:59,391 --> 00:10:03,802 can't really do anything about it, but by using more binary 114 00:10:03,802 --> 00:10:07,812 digits to represent the decimal numbers, we can minimize this 115 00:10:07,812 --> 00:10:15,535 problem. Let's look at another simple 116 00:10:15,535 --> 00:10:21,416 example, 4.715. Separate it again to whole and 117 00:10:21,416 --> 00:10:27,019 fractional. Part 4 is just 100. Remember this is 1, two and four 118 00:10:27,019 --> 00:10:31,760 and the fractional part will be 0.715. Now let's keep doubling 119 00:10:31,760 --> 00:10:38,656 it. 2 * 5 is then carried A1 three times, one is 2 + 1 is 120 00:10:38,656 --> 00:10:45,552 three 2 * 7 is 14, so I've got one of the overflow, so the 1st 121 00:10:45,552 --> 00:10:49,431 digit in after the radix point will be one. 122 00:10:49,490 --> 00:10:53,901 Now those two unnecessary anymore. So double again 2 * 3 123 00:10:53,901 --> 00:10:59,916 is Six 2 * 4 is 8, so there is no overflow. This digit will 124 00:10:59,916 --> 00:11:01,119 be at 0. 125 00:11:02,090 --> 00:11:08,516 Double it again. 2 * 6 is 12, carried A one 2 * 8016 + 1 makes 126 00:11:08,516 --> 00:11:12,674 17. I've got an overflow here now, so that's number one. 127 00:11:13,470 --> 00:11:20,529 Double it again. 2 * 2 is four 2 * 7 is 14. 128 00:11:21,170 --> 00:11:23,340 So next digit is 1. 129 00:11:24,230 --> 00:11:30,080 Double against that digits gone 2 * 4 is eight 2 * 4 is 8 130 00:11:30,080 --> 00:11:35,150 no overflow, so this digit phobia, 0 double 2 * 8 is 16, 131 00:11:35,150 --> 00:11:42,170 carried A one 2 * 8 is 16 + 1 is 17. So there is one as an 132 00:11:42,170 --> 00:11:47,630 overflow that's gone. Now double again 2 * 6 is 12, carried A one 133 00:11:47,630 --> 00:11:54,260 2 * 7 is 14 + 1 makes it 15, so I've got one as an overflow. 134 00:11:54,300 --> 00:12:01,440 Double again 2 * 2 is four 2 * 5 is 10. 135 00:12:01,970 --> 00:12:04,190 Overflow, so that's another one 136 00:12:04,190 --> 00:12:10,380 in there. Times 2 is 8000 is the next digit? Well, I don't know 137 00:12:10,380 --> 00:12:14,780 about you, but I'm getting exhausted in here and look there 138 00:12:14,780 --> 00:12:19,580 is not even a sign anywhere for a repetition, so this function 139 00:12:19,580 --> 00:12:23,580 looks even worse than the previous one. And again just 140 00:12:23,580 --> 00:12:28,780 look at it how simple this is in decimal. So yes, the binary 141 00:12:28,780 --> 00:12:32,780 number system indeed have got quite a few limitations which 142 00:12:32,780 --> 00:12:35,180 can get quite a bit annoying 143 00:12:35,180 --> 00:12:39,500 well. What kind of things have been discovered about the binary 144 00:12:39,500 --> 00:12:43,380 number system? Well, basically we know that not all decimal 145 00:12:43,380 --> 00:12:46,872 fractions can be expressed as a finite binary fraction. 146 00:12:46,872 --> 00:12:50,752 Unfortunately, this cannot be avoided, but can be minimized by 147 00:12:50,752 --> 00:12:55,408 using more bids. Also, if you look at the examples through the 148 00:12:55,408 --> 00:13:00,064 video again, you can see that the radix point is different for 149 00:13:00,064 --> 00:13:03,944 different numbers, so the position of the radix point is 150 00:13:03,944 --> 00:13:05,884 changing from number to number. 151 00:13:05,930 --> 00:13:09,857 That can get quite confusing for the computer, but Luckily for 152 00:13:09,857 --> 00:13:13,784 this problem we do have a solution and that is the 153 00:13:13,784 --> 00:13:17,711 floating point notation which we will talk about in more details 154 00:13:17,711 --> 00:13:21,638 in one of the following videos. For now I've prepared some 155 00:13:21,638 --> 00:13:26,279 examples for you, so please look at them. Try them and you will 156 00:13:26,279 --> 00:13:29,849 find the answers later, so these are the practice questions. 157 00:13:35,580 --> 00:13:37,560 And here are the answers.