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 010 and add until we reach 410:

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 1002 and 12:

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

Ex. Adding 1011012 and 1112:

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 102 + 102

2.

Create a new variable, answer2, and set it equal to the sum of 100102 + 1010112

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 11101110112 + 110101112

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?