Learn

Adding binary numbers can be done in much the same way that we add base 10 numbers, with a couple of caveats.

Let’s start at `0`10 and add until we reach `4`10:

Decimal Binary
0 + 1 = 1 0 + 1 = 1
1 + 1 = 2 1 + 1 = 10
2 + 1 = 3 10 + 1 = 11
3 + 1 = 4 11 + 1 = 100

We can see that when adding numbers we need to be very careful when carrying our numbers. This will happen much more frequently than we are used to with decimal numbers. Here are some important rules to remember when adding in binary:

• `1 + 0 = 1`
• `1 + 1 = 10`
• `1 + 1 + 1 = 11`

For larger numbers they can be lined up, one on top of another, just like in the regular addition you are used to. Take a look at the examples below, you can see how often you need to carry in binary addition.

Ex. Adding `100`2 and `1`2:

``````Binary | Decimal
|
100   |    4
+  1   |  + 1
----   |  ---
101   |    5       ``````

Ex. Adding `101101`2 and `111`2:

``````Binary  | Decimal
1111  |  1    <- carried digits
101101 |  45
+   111 | + 7
------- | ---
110100 |  52``````

### Instructions

1.

Create a new variable, `answer1`, and set it equal to the sum of `10`2 + `10`2

2.

Create a new variable, `answer2`, and set it equal to the sum of `10010`2 + `101011`2

3.

The previous two questions had very limited carrying, this number question will put your binary addition skills to the test! Create the variable, `answer3`, and set it equal to the sum of `1110111011`2 + `11010111`2