A foundational look at how processors handle binary addition, using a simple calculator project to illustrate how chips process data at the hardware level.
Building a Calculator
We're going to start creating a calculator by creating just a simple addition machine that's going to do some calculation, and we'll start seeing what the chip does to actually process data.
Here I have a very simplistic calculator, so I'm going to take a look at what it takes to add two numbers together to come up with an answer, and that's what we're going to use as our project.
One thing to understand is there are different numbering systems. The system that we're used to working with is the decimal system. It starts out with 0, 1, 2, 3, 4, 5, 6, 7 and so on and so forth. Binary looks quite a bit different. Binary starts out with zero, goes to 1 1 0 1 1 1 0 0 1 0 1 110 and 111.
I just want you to have a basic understanding that binary looks quite a bit different from the perspective of just looking at it, where sometimes it's a little hard to adapt to it because it's just ones and zeros, but in many ways they operate the same way.
Let's take a look at adding in both decimal and binary. With decimal, I'd start out with the ones column and add this together right here, so 0 + 1 is one. Then I go to the next column: 0 + 5 is 5. Then I go to the next column, 9 + 1, which is actually the hundreds column here — it resets to zero and then we carry a one into the thousands column, and there's nothing to add it to, so then we end up with 1,51.
With binary we do the same thing. We start with the rightmost column here, which is the ones. We add 0 + 1 and that is one. Then we go to what's actually the twos column — we won't get too deep into that — but that's 0 + 1, and so that's one as well. Then we go to the four column right here and that's 1 + 1, and we can't have a two in here, there's only zeros and ones. So what happens is that this four column gets reset to zero and we carry a one into the next column. Then what we see here is 1 + 0 + 0, which is 1, and so this is the answer of adding these two numbers together.
By the way, these numbers are much, much smaller than these numbers, and the answer is, let's see, it's an 8 plus a 2 plus a 1, so the answer over here is actually 11. This is the equivalent to a decimal 11.
So how does a calculator calculate this out? Let's just take one column, that first column here, and come up with some scenarios. We could have 0 plus 0, we could have 1 plus 0, we could have 0 + 1, and we could have 1 + 1. Those are the four scenarios we have with just that first column adding two numbers together.
Let's take this first one. Let's say there's a zero plus zero, so input one is zero and input two is zero, so we've got zero and zero right here. Then what is the answer of that going to be? This isn't a trick question: 0 plus 0 is zero, so we're going to just say zero right here. So the output here is zero.
If you've got the grasp of that, try to figure out the rest of this table and see if you can figure out what the rest of the table is going to be, and then we'll do it together.
Let's see what the rest of these are. In this next scenario right here it's 1 + 0, so 1 and zero are the inputs here, and we can see that that's going to be one, so the output is going to be one. 0 + 1 is this one right here, which the answer is one there, so we've got that. And then 1 + 1 — this is where this column gets reset and we carry a one into the next column. So what that looks like is we're going to put a zero as the output, this is the output right here, and what we're going to do is carry the one into the next column, so the one right here. In fact we can fill in the rest of this chart: this was zero the rest of the time.
So now we've made a chart for the output of these four different scenarios. We're going to play around with these charts a little bit more when we get into gates, but this just dips your toe in it. So if you didn't get that, don't worry about it, we're going to progress on from here, and I'm actually going to present this again later.
What a calculator is going to do is it's going to do that for the first column, and then it will do it for the second column, then the third column, then the fourth column.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →