[Music] foreign [Music] let's start with a nice and simple one so this one here is asking what kind of data we can represent with binary sequences it gives us three options it gives us a string of characters right over here colors or audio recordings and the answer to these types of questions is pretty much always going to be all of the above because the key here is that computers can represent everything as binary sequences and in fact it needs to represent everything as binary sequences because that's how the hardware interprets the data using on and off states of electricity now this question here is very similar but it's trying to throw you a little curveball by offering this option right over here machine language instruction now it's making it sound like maybe this is something a little different but it's actually not all this comes down to is that your code when you're finished writing it is going to turn into binary it's going to compile into zeros and ones and that's how the computer is able to read your code so just like you can represent integers which we know from the first time we learn binary and we know you can represent alphanumeric characters such as using an ASCII chart we also represent machine language instructions as what we call binaries which is your compiled code which then the computer can actually read and do something with making the answer here also one all the above usually the answer to these is all of the above now this question here is going to try to disambiguate between analog and digital so analog is what is used to refer to basically images or sounds or other things that have a continuous type of structure so for example you might think of sound an analog as having kind of this continuous type of value right so here you might have a value that's something like I don't know 10.6 or something right now digital is very different digital is represented by bits and it's what modern computers use you might think of the same type of data in digital kind of represented in a kind of blockier sort of way maybe something kind of like this and you might imagine that the values of this are not going to be continuous so for example this same value here might just be 10 this value here might be 3 while this might be like 3.3 2.6 or something right and these would be represented as binary for example you would have here your 0 1 1 for your three and your 10 here might be your one zero one zero it's better so what this comes down to is that we need to find regions of this and kind of extrapolate them into what would be our binary equivalent this process right here is what's called sampling the way sampling works is you take a set of values in analog such as this analog audio signal you measure it at regular intervals each of these measurements is called a sample and the sample is represented as a sequence of bits as such the answer to this one here is B the difference between analog data and Digital Data overall is that analog is continuous and Digital Data is not you have a fixed number of bits so you have to pick parts of the sample of your analog data and represent those as bits a similar idea to analog and digital is the idea of overflow and round off errors both of these happen because you have a fixed number of bits to try to represent an unlimited number of information so for example numbers are infinite they go as high as you can imagine much like there's numbers between numbers there's fractions within fractions however when you're dealing with Digital Data you only have a fixed number of bits so let's look at this question to see how this ties into overflow so in this question here we have basically two positive integers and they are added together and eventually they lead to an overflow error so this is asking which of these explains how an overflow error happens so the best way to explain how an overflow error happens imagine if we're using decimals not think about binary here and let's say we're adding 99 plus one however let's say that I tell you that you can only use two place values two digits right so the value of this is a hundred but if you only use two digits the best you can represent here is zero zero so with just two digits 99 plus one just gives you zero right and what that means is that we've overflowed instead of going to 100 we wrap right back around to zero so let's go back to Binary world let's say that we have at most three bits right so let's say that the highest number we can represent is one one in binary which we know is seven if we add one of that we're going to end up with eight which is one zero zero zero now if I tell you that you can only represent up to three bits then suddenly you don't get this last bit right here so one one one plus one so seven plus one will just go back to being zero this is what is Overflow as described here this means that the program can only use a fixed number of bits in this example those three and the computed sum is greater than the maximum representable value so in this example the computed sum was eight right and the maximum value was seven now round off is a similar concept to overflow but it's a little bit different overflow deals with things being larger than your maximum allowable number of bits round off is similar but it deals with numbers being more precise than what you can muster so let's give an example here let's make a little timeline here or a number line and let's say numbers between 10 and 0. and this is going to be just in decimal now in mathematics we know that there's really an infinite number of values between this we can have a value here which is you know like 2.13 all the way down and there's any number of decimals that you can imagine between the numbers 0 and 10. unfortunately when we're dealing with digital data we don't have an unlimited number of bits to represent this we might only have for example 8 Bits or 16 bits or 32 bits so if you have 32 bits you will only be able to represent a certain number of things even if you can represent decimals what this means is that there is going to be some numbers some Precision of numbers some very specific decimal that you're not going to be able to represent you just don't have an infinite number of bits so this rules out this concept right here so these options are nonsense the account balances are represented by an unlimited number of bits obviously we know that we have a fixed limited number of bits so these are definitely not correct we also know this is not about overflow this is talking here about numbers being mathematically and precise so we're talking about imprecision we're not really talking about overflow overflow means that we're trying to represent a number that's too big what this is is round off errors roundoff errors is when you want a number to be very precise but you just don't have enough bits to represent that that's exactly what we're dealing with here now here's an interesting problem this one's going to be about the number of things we can represent with binary numbers now in this scenario here we have a video game and the video game has different movements represented by up say left right and down now in this video game here they gave these different numbers right so it says that each direction is stored in memory as a sequence of four bits and notice that the four bits is very important here so we have four bits and let's say we represent these as follows maybe this is zero maybe this is one this is two this is three doesn't really matter which numbers we use for which just matters that we can represent that many now for this we actually only need two bits right we have zero we have one we have two and we have three now it says we're going to add four additional things right we're going to add Northwest these Southwest Southeast and we'll call these four five six and seven now we know that we actually don't need more than four bits to represent that we can do four five six and seven so here we have zero one two three four five six seven so as we can see here with four bits we actually have way more than we need and as such four bits are more than enough to store the eight directions don't think about bits as the absolute number of things you can represent four bits doesn't mean you only represent four things four bits is what you can use to generate the numbers that you can represent so here with four bits you see that we can actually go all the way up to 16 right so this is four bits the maximum number is 15 right over here so we can go from 0 to 15. all right now here's a pretty tricky problem so in this one here we start with this number right here and it says it's going to transform it into this number by basically adding three zeros to the end in fact what it's asking here is which of the following correctly describes the relationship between these two numbers now this might make you think that what you want to do is to calculate the actual value of this thing and the value of this thing and compare them that's actually quite a lot of work because this is a pretty big number now you can do it that way and we're going to do it that way as well but what I actually want to show you is a simpler way what a pressure can do here is actually to do the same transformation to a smaller number let's say a nice and small number such as about a number one so if we do that for the number one we add three zeros to the end let's see what we do we have 0 0 1 and we add three zeros we actually just end up with the number eight it says decimal for eight we could try the same with number two so we start with the number two and we add three zeros we actually end up with 16. we know that if this is eight this is 16 right here right one two four eight sixteen and for good measure we can do the same thing with four this is one this is two and four so we start with one zero zero we add three zeros now we have 32 1 2 4 8 16 32 so the relationship between these eight is eight times more than one sixteen is eight times more than two thirty-two is eight times more than four you can see we get the same type of result no matter what we do as it turns out that's what the answer is the transform number is eight times the value of the original number this is probably the easiest way to come up with this is you start with just a really simple example of it the reason this works is because you're actually adding three Bits And as you might recall whenever you add a bit you multiply the value of it by two actually whenever you add this 0 to the end you multiply by two if you got two zeros you multiply by four if you add three zeros you multiply by eight now that's kind of a hard rule to remember so in the pressure of the exam it's probably just better to just remember to try with a really simple example now that out of the way let's try it with the actual numbers and see if this works out to be the same and to evaluate these numbers they're pretty big so we're going to start with a pretty big number line here so we do one two so that should be enough now let's uh try to see what these numbers are so the first one we have on the right is zero zero zero and then we have a one here a zero here and one one one so it says 128 plus 64 plus 32 Plus 8 and he throws into the calculator [Music] or just do it in your head get 232 let's see what the other value is so this is 232. now let's do this other one this one's this one's one zero one one one so this is 16 plus 8 plus 4 plus 1 which is 29 right it's 29 and the other one was 232 and we know that if we divide 232 by 29 we will get eight or maybe you don't put your calculator does now all that said even though we solved it out in the end by actually converting the numbers I don't recommend doing it that way I think it's better in this kind of example to pick a simplified example like we started with one two and four and see what happens with those and see if you can spot the pattern on those all right well I'm here with a really tough one they actually really like to ask this question so let's go over it real quick so this looks like it's about the internet because it's talking about ipv4 but it's actually not this is about binary so here's the question it says that we have an IP address we start out with a 32-bit address right which is a pe4 and now it says that it's going to represent this IP using IPv6 which is going to use a 128 bit dress instead so the question here is not about IP at all actually the question is about how many more IPS can we represent using 128 bits rather than 92 bits what this is saying basically is if you add 96 more bits how many more things can you represent now you might be tempted right away to think about this and say okay it's going to be 96 times as many right you just add 96 more bits 96 times more things to represent but by now you might recognize this is not really how it works right binary doesn't work that way when you add another bit you don't just add one other option you add twice as many options when you add two bits you add four times as many options when you add three bits it's eight times as many options let's illustrate why it works that way the simplest example of how this works out is think about having just two bits right with two bits you have these numbers you have zero zero you have zero one one zero and of one one that's four total right this is four now you know that if we add one more bit we would get the following options we would have a good friend zero zero zero we would have zero zero one this is a total of eight now let me show it to you this way because this might actually help you illustrate why this actually goes up by twice as many instead of just drawing them out let's actually copy these out like this put them over here put them over here now if we add one bit we can now represent these as all of the previous combinations as before with zeros here and then all the combinations as before with a one here so we did all the previous combinations so all these four things with a zero and then all of these four things with a one so essentially by adding the bit we actually duplicate how many things we can represent and the same thing is true if we add one more bit so let's take this let's make it real small and let's do the same thing let's say we're going to add all zeros over here and all ones over here as you can see we've duplicated this so now instead of eight we went from 8 to 16. what does this mean whenever you add a bit we duplicate the amount of things it can represent so how does this help us with this problem let's take a look so to illustrate how this works at a higher level let's look at it this way let's say that on the left here you have bits let's start with two and here you have combinations of say combos higher the highest number you can represent so we know that with two bits we have four the three we can go all the way up to eight with four bits we can go all the way up to sixteen five bits you can go all the way up to 32 with six bits we can go all the way up to 64. now what does this mean let's look at if we go from Two Bits to four bits we get four times as many we go from Two Bits to five bits we get eight times as many we go from Two Bits to six bits so we're adding four bits we get sixteen times as many if I want to go from two to six I am multiplying how many combinations I get here by two times two times two times two which is the same thing as two to the fourth to go to seven so it should go from two to seven I have five more bits which is two times two times two times two times two as many combinations which is two to the five so what's the moral here if you add ten bits you get 2 to the ten times as many if you add 20 bits you get two to the twenty times as many right this is basically two times two times two all the way to 20 right so what happens if we have 96 more bits well if you add 96 bits then you will have 2 to the 96 times as many which is answer d it's a very common question that you might get asked so it's good to know how to do it thanks for watching I'm Flavio and I'll be back with more soon [Music]