 Hello everyone, it is Crypto Grounds here and welcome back to another video. This is the first episode of the brand new binary series I have started on YouTube and I'm very excited to be able to start this. So the first episode today is going to be the very basics of binary so I'm going to be explaining some basic terms, what binary numbers actually are, how to convert binary numbers to decimal numbers and I'll show you the math behind them. Anyways, let's jump right to the whiteboard. So on the whiteboard we have a very basic binary number and this has four digits in it. A digit in binary is called a bit so we have a four bit binary number. What does this actually mean? What is this actually equate to? Well this is just zero zero zero zero in binary. However, we can convert this into decimal form which is our standard number system. Let's come back to this example in a second. Let me write out another one. Okay, so we have a one in the first bit now. What does this mean? So when we add one to this zero zero zero zero binary number, we get this and this is actually equal to one. Okay, let's explore. Let's add another one to here. So bits can either be zero or one. There's no two, three, four, five binary. There's only two different numbers a bit can be zero or one. So when we add one to this binary number here, we get this binary number. So we know that this is two and when we look at this we can try to determine what each of these bits actually mean. So if this is one and these are all zeros except for this one, this first bit must equal to one. For this example, if these three bits, the fourth, third, and first are all zeros but the second one is a one, this must equal two. So this second bit is two. So now we're starting to get into a pattern here. So we can determine that if these bits each have values to them, this up here must equal zero. So these could be anything but since these are all zeros, this binary number must be zero and decimal. So let's try to figure out what this third bit actually is. So remember, I am adding one to every single binary number. So this right here is just this binary number plus one. So we know that this is going to be three. And we know that by the first two bits are ones and that is two plus one. And now when we add one to this three, we get four. So this is going to be four. And we now know what the third bit is worth. This is four. And we know this because the fourth, the second, and the first bit are zeros except for the third one. And this is the only one. So this must be four. So we can see we're starting to get a pattern here. For every bit, it's doubling its value. So we can say that this fourth bit is going to be eight because it is four times two. So why is it like this? Why does this work? I'm going to be showing you guys the math behind this. Okay, so I have written up a new number, 1011. Again, this is still a four bit binary number. Let's determine what this is in decimal. So let's rewrite the values of each bit, one, two, four, and eight. So now we just got to add these together. We have eight plus two plus one and we get 11. So this binary number is 11 in base 10 or a decimal. I like to clarify that the difference between this and this one is that this is base two. So we can add a little subscript here called two and a subscript of 10 here. But that's just optional. This is just determined that this is a base two number and this is base 10. We call this decimal and we call this binary. Let me write that up. So now that we know how to get the base 10 value of this binary number, I'm going to show you the math behind it and why this actually works. Because it's more than just saying, this is one, two, four, and eight. There's actually an equation behind it. So each bit is multiplied by two. So we know that, OK, so let's say this is the first bit. This is the second bit and this is the third bit and this is the fourth bit. When we plug an n into something, we are trying to get the value of this bit here. And remember, this multiplies by two. So how do we get this? Well, we take two to the power of n and we get this value. Except two to the power of one is two, not one. So we subtract this n by one. OK, so this first one, two to the power of one minus one. That would be right here. This would be the first bit. OK, so when we get that, we get two to the power of zero. And that is equal to one. Anything to the power of zero is always going to be one. All right, so two to the power of two minus one. That is going to be two to the power of one, which is equal to two. Two to the power of three minus one is going to be two to the power of two, which is equal to four. Two to the power of four minus one is going to be two to the power of three. And that is equal to eight. You see the pattern now? Is it all starting to make sense? Now let's plug this all together so we can somehow add all of these up and end up with 11. Because basically the base 10 version of the binary number is just a sum of these. But we multiply them by 0 or 1. That's why it gives us a value. If this bit is 0, this third bit is going to be worth 0, not 4. However, if this was 1 right here, we would have 8 plus 4 plus 2 plus 1, not 8 plus 2 plus 1, if that makes sense. So let me get rid of all this and let's write it all out. So let's go backwards for this one, because we're eventually going to write an equation where it actually goes backwards. And that's just how it's going to make sense in the future. So first, let's start with our bit. So that would be 1. We multiply this by 2 to the power of n minus 1, which is 0. So we do 1 times 2 to the power of 0. Let's write out the rest. So the second bit is going to be 1 or plus 1 times 2 to the power of 1. Next, we have plus 0 times 2 to the power of 2. And last but not least, we add 1 times 2 to the power of 3. OK, so we have a sequence here. Let's add these all up. So 1 times 2 to the power of 0, remember, 2 to the power of 0 is 1. So we're basically just multiplying 1 times 1. So we get 1. Then we add 1 times 2 to the power of 1, which is going to be 1 times 2. So we get 2. So we have a 0 here. So this is going to be 0 regardless of what this value is here. Because whenever we multiply anything by 0, we're going to get 0. So 0 times 2 to the power of 2 is going to be 0 times 4, which is 0. Last but not least, 1 times 2 to the power of 3. So that is going to be 1 times 8. And here we go. This is so clearly familiar. Let's add this all together, and we get 11. So things should start clicking now. Things are starting to kind of make sense on why this works. This is a lot of writing, especially when we have larger numbers. It's going to get more complex. I have a formula, so let's write that out. So it all starts with this symbol right here. And this is called the sigma. So what we're doing with this, we are making a sum of a sequence. So this is our sequence right here. So we have this little segment here. We add it to our sum equation here. And it can basically just perform this entire sequence with just a few parameters. And it saves us from having to write out a lot of stuff. So before we actually get to the parameters of this sum, let's write out this equation. So first we have our 1. So this is either 0 or 1. And I'm just going to write that as b for bit. All right, so next we multiply this by 2. So we're going to have this for everything, right? If we want to convert a base 2 number into base 10, we multiply the bit by 2. And we raise it to the power of whatever this number is. How do we get that number? Well, it's right here. It's n minus 1. So we have b times 2 to the power of n minus 1. And remember, b is whatever the value of the bit is. And also just to give some clarity on what bit this actually is, we can put a subscript for n minus 1 down here. Let me rewrite it so it looks a little better. All right, so here's our equation. Now let's figure out the parameters here. If you want to solve a 4-bit binary number like this one, we need to start at n equals 0. So that will be this one right here. But we subtract 1 from n. So we technically start at 1, the first bit. So we have n equals 1 at the bottom. This basically just tells us that we need to start at n equals 1. And that will start right here. So when do we want to end? We want to end at n equals 4. So we just put 4 at the top. This basically tells us we are going to loop through this sequence right here. And we're going to add up everything from n equals 1 to n equals 4. So it's going to go 4 times. And so there's another way of writing this. Whatever makes more sense to you. Let me write the other one. So please note that both of these are valid. They're just shifted a little differently. The only difference between this one and this one is that we start from 0 and we end at 3. And instead of subtracting 1 from both of these ends, we just use n. Basically, these are exactly the same thing. And as you could see, they both match all of these bit numbers here. So let's rewrite this as the long form right here. Just so I can show you what it actually looks like when it's in action. So this is a bit small. I apologize. But basically, when we unfold this sum, we get something like this. So we have our bit number. And this will be the first bit right here. We multiply it by 2 to the power of 1 minus 1. And we go all the way down to when n is equal to 4. So this is what it looks like. It looks very similar to this, except we just don't have the actual bit values. We have an 8-bit binary number now. And I'd like to clarify that this is considered 1 byte. A byte is equal to 8 bits. So when we have 2 bytes, we have a 16 bit binary number. So before converting this into a base 10 or decimal number, let's find out what each of these values are. So we know the first four bits. It's 8, 4, 2, and 1. But remember, each of these multiply by 2 for every bit. So we know that this is going to be 16. This 6-1 is going to be 32, 64, and the 8-bit is going to be 128. So we can now finally plug this all together. And I'm not going to do it like we did before. I'm just going to do the basic quick shortcut method. So we have 64 plus 8 plus 4 plus 1. And when we add all of this together, we get 72 plus 5. And that is 77. So this binary number is 77 in base 10. So now let's do a situation where they're all 1. When we add all of these together, we have 128, 64, 32, 16, and so on. When we add all of these together, we get the value of 255. So note that the max value for this specific type, and I'll explain later, this specific type of binary number, the max value of this is going to be 255. And that's when all of these are 1s. So what I mean by type is that we can treat this binary number in two different ways. We can treat it as a negative number or a positive number. We are treating this as a positive number. And now I'll explain that more in the next episode. So stay tuned for that. So before we start wrapping up, I'd like to show you guys some basic addition. So we have 0011 plus 0101. This first binary number in base 10 is going to be 3. The second one is going to be 4 plus 1, so this is going to be 5. So when we add these together, we should get the value of 8. So let's do some addition. So we need 1 plus 1, these two cancel out. So this becomes 0, and we carry over the 1. So we need 1 plus 1, we get 0 as well. And we bring and we carry over the 1. 1 plus 1 again, this is 0. And we carry the 1 to the last bit. And 1 plus all these 0s is going to be 1. So remember, this is 8, 4, 2, 1. So this is indeed 8. That's correct. Remember when I said earlier that we can treat this binary number in two different ways. Well, I didn't really specify too much for a reason. I made this fourth bit a 1. I'm going to treat this binary number as a negative value. So this is actually going to be negative 4. So we have all of these right here, which is 4. And then we have our negative number. This is our sign bit. So when we add these together, we should get negative 1. However, there's a problem here. We don't. And let me show you why. So let's add these together. So we have 1 plus 0. That is 1, 1, 1, and 1. So this would be all 1s. However, this is a negative 1. This is actually negative. We have 4, 2, 1. This is actually negative 7. And last time I checked, negative 7 actually is equal to negative 1, right? So we have an issue here. And we go over this in episode 2 and 3. We have to convert this binary number. Well, fundamentally, we have to convert this binary number into something else. And we will get into that in the next two episodes. If you enjoyed this episode of Learn Binary, make sure you leave a like, subscribe if you want to see more content like this. And if you want to be notified for whenever upload videos, hit that bell and turn on all notifications. If you want to support the channel, check out the Patreon link in the description below. And I just want to say thank you guys very much for watching this. And I really hope you guys learned something from this. It was really fun making this video. And I really enjoy talking about this kind of stuff. I will see you guys in episode 2, which will be on signed and unsigned binary numbers. I hope you guys all have a great rest of your day or night. And I can't wait to see you guys in episode 2. Peace. I'll be up in class, but my mind is in the clouds, though. Know the teacher's mad, because my music beating loud, ho. Tell me keep it down, say I kill it on the down low. And if I turn it up, then I'm bound to attract the crowd. So no wonder me and Tim be out of state, doing the things you can't imagine. Chris Angel on the mic and me a beat. I'll show you magic. We born in different planes.