# Beginner Electronics - Beginner Electronics – 27 – Intro to Binary

## Beginner Electronics

29 Lessons

### Beginner Electronics – 27 – Intro to Binary

what is going on everyone my name is code Moore and welcome back to electronics episode 27 in this episode we are going to learn about the binary

number system now if you already know binary and you're really comfortable with it you can feel free to skip this video but if you don't know binary very well I highly recommend watching this

video because when we make our 8-bit computer we are going to be using binary for literally everything our computer commands are gonna be binary or all of our numbers are gonna be binary all of

our math is gonna be in binary so you really have to begin getting comfortable with this binary system and we will have plenty of practice with this as we go along with this series now I've found

that the easiest way to explain binary to someone is to start with what we already know and for the most part we all count in base ten so what exactly does base 10 really mean well for

starters it means that we can use the digits 0 1 2 all the way up to the digit 9 so we have 10 total digits 0 through 9 to work with the next important thing to note and this is something that we do

without even really thinking about it is that the position of each digit in base 10 in our numbering system has a very specific meaning so if we have the number 8 well we know that's the value 8

but now let's take a look at the number 1 8 now if this number 1 was on its own then it would only represent well the value 1 but this one is in the left position it's in the second position

over in this number and obviously we know this has the number 18 so basically whatever digit is over here to the left really doesn't represent 1 anymore that represents that we have one group of 10

essentially so this really equals 10 and then we add on our single digit 8 here and of course that gets us well the value 18 is sort of hard to write it like that

and of course as you move further over if there is another digit here well this would actually be worth a hundred times whatever the digit is here so if there's a 2 here well this is worth 200 and then

you'd add that to the rest and you get well 218 it's really easy for us to overlook these simple little thing because we do it automatically in our mind all of the time so let's really

quickly break this down into more of a mathematical formula say we have a number that's worth three three digits say we have a three-digit number here I don't know let's make it 314 the further

left you go the more significance the digit has then the more significant that digit is and we and we can represent this using powers of 10 so the digit in the rightmost place here

well this is worth it's value multiplied by 10 to the 0 and the next place over is whatever the digit is here but multiplied by 10 to the first power and then more digits

over this is would be the digit 3 multiplied by 10 to the second power and of course this would continue onwards as we go more and more to the left obviously 10 to the 0 here well that

just equals 1 anything to the power of 0 is a 1 10 to the 1 equals you guessed it 10 and 10 to the 2 equals 100 of course so in essence what we're really doing when we see this number 314 we're really

taking each of the digits so we're doing 3 multiplied by its positional value which is 100 then we're adding that to 1 multiplied by 10 its positional value and then we're adding that to 4

multiplied by its positional value which is just 1 so of course we get 300 plus 10 plus 4 and we get the exact same thing that we wrote 314 and trust me this is all gonna play in till when we

move on over to binary here so we use the base 10 number system while binary is a number system itself it is just the base 2 number system hence by and binary and if we go based off of what we

learned about the base 10 number system which was we have 10 digits to work from 0 through 9 well when we look at the binary system here that this means we have the digits 0 & 1 to work with we

only have two digits to work and this is really really great for computers and for digital electronics because a zero can just be represented by low or essentially connected to

ground and a one can be represented by high or essentially voltage and this is why binary is used so often in computing and all these types of electronics is because it's so simple to represent

using voltage using simple circuits and logic gates like we discussed in the previous video so when you're reading binary you kind of have to change the way that you think and most often that

results in you trying to convert from binary to base 10 something that we can really understand so if I just have a single digit binary number say 0 that just equals 0 in base 10 cool I

understand that if I have a binary number 1 that just represents 1 in base 10 cool I understand that but what if I have 1 0 well this is not equal to the number 10 in base 10 number system

instead 1 0 is really equal to the number 2 in the base 10 number system so how did I figure this out how do I know that 1 0 equals 2 in our normal system well let's take a number let's say well

let me go off of what I just discussed so we have the number 1 0 the number further to the left is gonna be more significant it's gonna its value is gonna be more than all the numbers to

the right of it so remember in base 10 when we multiplied this by 10 to the 0 and by 10 to the 1 well instead of doing that of course we are instead gonna multiply these by 2 to the 0 and we'll

multiply this digit here by 2 to the power of 1 and we're using 2 because well we're in base 2 we only have two digits to work from and this is where things get not complicated but a little

bit hairy because here we have binary so we have 1 0 and binary and the multiplication that we're doing with these powers of 2 down here well this is in base 10 so essentially I'm teaching

you right now how to convert from binary into base 10 because that's the easiest way to begin to understand binary and to be able to recognize what a binary value actually equals in base 10 so 2 ^ 0

again this is just normal math as you would do it everyday of course is 1 anything the power 0 is 1 2 to the power of 1 is just 2 now all we have to do is multiply

the digit by its place value that we assigned to it so here we're gonna have 1 multiplied by 2 plus 0 multiplied by 1 of course this is just going to be 2 plus 0 equals 2 in base 10 so we know

that 1 0 equals 2 in base 10 and that's all there is to binary and this is exactly how you would convert from binary into base 10 so if we take a look at the math I did here we're doing

essentially the exact same thing that I just showed over here only over here our top numbers were also in base 10 and over here there instead in base 2 so let's do a little bit more work here

with binary let's get a little more comfortable with it let's say I have a nice large number well not too too large but let's say I have a 5 digit binary number and I'm just gonna try my best to

write binary in base 10 that way we don't get confused here now let's say I have the number 1 0 0 1 1 well I have no idea what this means so let's go ahead and convert this

number in to base 10 and by the way right after I finished this example I'm going to show you kind of the shortcut that I take in my head to process these binary numbers that's a little simpler

than writing out all this math all the time remember that the rightmost digit is just going to be it multiplied to the power of 0 this one's going to be multiplied by 2 to the power of 1 sorry

over here I meant 2 to the power of 0 the next one over 2 to the power of 2 2 to the power of 3 and 2 to the power of 4 now 2 to the power of 4 is 16 2 to the power of 3s 8 to the power of 2 is 4 2

to the power of 1 is 2 2 to the power of 0 is 1 so now we know exactly what to do we have digit 1 multiplied by 16 plus digit 0 multiplied by 8 plus another digit 0 this time multiplied by 4 plus I

digit 1 multiplied by 2 and plus a digit 1 multiplied by 1 so here we wind up having 16 plus all of this is zero plus two plus one and I'm just can't raise zero here so

this all equals 19 and that's of course in base 10 so we know that 1 0 0 1 1 is simply 19 in base 10 in the way that we understand numbers now I'm gonna teach you a really quick trick now this trick

might not work for everyone this is just how my brain processes information so maybe it'll help someone out there my brain can pretty easily take a number and just double it it can just my brain

can easily multiply this by 2 so if I start with the number 1 on the right here and I just start multiplying by 2 so 1 times 2 is 2 and then I continue this to the left so I take 2 and

multiply it by 2 I get 4 take 4 multiply it by 2 I get 8 8 multiplied by 2 I get 16 32 64 128 and so on I can do that pretty easily in my mind so when I'm thinking of a binary number let's get an

example number of say 0 0 1 0 1 1 1 0 in my head I just calculate from right to left and start adding up digits together so I know ok no one I see a 1 here which means I have to add 2 to my result ok 1

here so I have to add forward or my result 1 here so I have to add 8 to my result 0 so I don't have to do with 16 there's a 1 here so I have to add a 32 to my result that was a absolutely

messed up 3 and then there's a 0 for 64 so I don't need a 6404 128 so I don't need a 128 so I know that this number is 32 plus 8 that's 40 plus 4 plus 2 that is 46 in base 10 so I know that the

number 1 0 1 1 1 0 is 46 so I don't even worry about all this power stuff that just confuses me more all I do is in my head multiply starting from 1 all the way by 2 each time as I go to the left

so we can go from binary to base 10 really easily but say we want to go from base 10 into now there's some mathematical ways you can do this at all but pretty much the

only way I'm going to show you and really to be honest the only thing that you need when we're only working with 8 bits at a time is pretty trivial so let me write out that whole sequence of 2 I

had so 1 2 4 8 16 32 64 and 128 now let me say that I have some number in base 10 that I want to convert into binary so let's say I want to take a hundred and five in base 10 and go into binary what

in the world would that be well start all the way to the left at the largest digit that you have in your in your binary number or whatever in this case of eight bits which by the way eight

bits basically means we only have eight binary places to work with then all I'm gonna do is ask myself does 128 fit into 105 no so this must be a zero does 64 fit into 105 yes so it's gonna become a

1 because I need a value of 64 so now I'll take my 105 and I will subtract 64 from it and that will leave us with 41 okay so let's continue onwards here does 32 fit in to 41 well yes it does so that

means I need another one here and of course I will subtract 32 from 41 now and this will leave me with 9 remaining ok does 16 fit into 9 no so that must be 0 does it fit into 9 yes so that's gonna

become a 1 and I'll subtract 8 and I'm left with a 1 so obviously 4 does not fit into one 2 does not fit into one of course 1 fits into one so there will be a 1 at the end and boom I am at 0 with

some crooked sideways math as I like to do and we know that a hundred and five that's a bad zero a hundred and five in base 10 is equal to zero one one zero one zero zero one in base 2 in binary

and of course we can leave out this last zero any zeros to the left won't change the answer at all and that's all I have for binary today now in my experience people have kind of a hard time

understanding binary sometimes especially when you're trying to convert back and forth from decimal into binary so you can try to understand it but I can promise you that if you do it long

enough and you try and you keep working and trying to understand what these numbers mean given time you're gonna be almost instant at converting binary numbers or at least the small ones like

8 bits and eventually it's just gonna become second nature for you and you're gonna be able to calculate these small binary numbers and instantly know what they mean in your head so if you're

really serious about this take some time maybe practice binary make sure you can understand converting from binary to base 10 and we're also gonna have quite a bit of practice with this in the next

few videos along with the rest of this series so thank you all so much for watching and I'll see you all in the next video

Today we learn about the binary number system (base 2), and how to convert to and from it!

Need source code? See my website: https://codenmore.github.io/