# Fundamentals of Data Representation: Binary arithmetic

 ← Binary number system Binary arithmetic Binary fractions →

You should be comfortable with adding, subtracting and multiplying in decimal. Computers need to do the same in binary, and you need to know it for the exam!

Let's look at an example of adding in decimal:

25
+43
---
68

This is pretty simple, we just add up each column, but what happens if we have can't fit the result in one column. We'll have to use a carry bit:

98
+57
---
155
11

Hopefully you're good with that. Now let's take a look at how it's done in binary with a very quick example, with a check in denary:

01010 (1010)
+00101 (510)
------
01111 (1510)

This seems pretty straight forward, but what happens when we have a carry bit? Well pretty much the same as in denary:

01011 (1110)
+00001 (110)
------
01100 (1210)
11
How carry bits are used in binary addition
 Exercise: Binary Addition 1010 + 0001 Answer : 1010 +0001 ---- 1011 01001001 + 00110000 Answer : 01001001 +00110000 -------- 01111001 01010100 + 00110000 Answer : 01010100 +00110000 -------- 10000100 01001010 + 00011011 Answer : 01001010 +00011011 -------- 01100101 01111101 + 00011001 Answer : 01111101 +00011001 -------- 10010110 00011111 + 00011111 Answer : 00011111 +00011111 -------- 00111110 10101010 + 01110000 Answer : 10101010 +01110000 -------- 100011010 Note we have some overflow, this will come in useful when doing subtraction

### Multiplication

You should hopefully have learnt how to multiply numbers together in decimal when you were at primary school. Let's recap:

12
x 4
--
8   =  4*2
40   =  4*10
--
48

And with a more complicated example:

12
x14
--
8   =  4 * 2
40   =  4 * 10
20   =  10* 2
100   =  10* 10
--
168

The same principle applies with binary. Let's take a look at an example:

101
x 10
----
0   =  0 * 101
1010   = 10 * 101 [or in denary 2 * 5 = 10]

Let's try a more complicated example:

1011 [11]
x 111 [7]
----
1011 =   1 * 1011
10110 =  10 * 1011
101100 = 100 * 1011