Section 2: Binary Digit Arithmetic

As previously mentioned, binary strictly uses 0 and 1. There are no decimals, there are no negative numbers (however we can clearly still interpret binary numbers as negatives as computers do, which we will talk about at a later time), and there are no digits greater than 1. With those facts in mind, let’s take a look at some math.

Let’s start with multiplication. Multiplication of binary numbers makes perfect sense in conjunction with what you already know about multiplication.

0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1

Makes perfect sense, right? But do you recognize that set of inputs and outputs at all?

That’s essentially the truth table for the AND boolean operation! So we can really think of binary multiplication as an AND operation.

Addition makes sense in mostly the same way.

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 1

Makes perfect sense again, right? Wait…what’s that you say? That last one is wrong? A great way to explain this that I have seen online elsewhere is that 1 + 1 is most definitely not zero, which we can all agree on. However, then the only other option is 1, so it must be 1. Now, there are plenty of other explanations for this as well, most prominently the fact that in many programming and scripting languages 0 is synonymous with false. If you have anything that is non-zero, then, you have a true value instead. So since 1 + 1 > 0, it is true rather than false so we get a 1 instead of a 0. Regardless of how we justify that it works, does that set of information look familiar?

You guessed it…that’s the same as the truth table for OR! So OR is basically binary addition…for the most part.

Another way we can look at addition is by looking at more than just a single bit. Consider the following set of addition using two bits instead.

00 + 00 = 00
00 + 01 = 01
01 + 00 = 01
01 + 01 = 10

This time each line does indeed follow mathematical addition. (Remember that the right-most digit is the 1’s place, next comes the 2’s, then the 4’s, then 8’s, 16’s, etc. as you move to the left.)

Notice that I highlighted the units (1’s) digit in each sum. Does this pattern look familiar at all? Perhaps seeing it in its own box might help, and without the two’s digits.

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0
That one is the XOR operation!

Each of these shows how we might connect arithmetic with binary to some boolean operations. Binary has many other applications related to boolean operations as well, which we will look at in the next section.


← Previous PageNext Page →