Digital data - CCEABinary addition

What is digital data, and how do computers understand it? How is digital data represented, stored, shared and manipulated?

Part ofDigital Technology (CCEA)Digital development concepts (programming)

Binary addition

addition is very like decimal addition, except that it carries on a value of 2 instead of a value of 10.

In decimal, if you add 8 + 2 you get 10. This gives the digit 0 and a carry of 1.

In binary addition, when you add 1 and 1 the result is 2. But since 2 is written as 10 in binary, we get the digit 0 and a carry of 1.

Therefore, in binary:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 10 (which is 0 carry 1)
  • 1 + 1 + 1 = 11 (which is 1 carry 1)

How do you work out a binary sum?

Adding two bytes

Sometimes a binary addition requires you to carry over values into the next highest place-value column, e.g. when finding the sum of the two bytes 0010 and 0111.

When adding two ones in the same column, the resulting value in the that column is 0, with 1 carried over:

In binary, 0010+0111=1001

The sume of the two bytes 0010 and 0111 is therefore 1001.

Overflow errors

An occurs when the total from adding binary numbers cannot be stored within the registers of a CPU. Consider an 8-bit processor – the largest number we can store in 8 bits is 11111111 (or 255).

If the result of the addition is greater than 255, an overflow error will occur as we do not have room to store the ninth bit. When this happens, the CPU drops the overflow digit because the computer cannot store it anywhere, and the computer thinks 255 + 1 = 0.

An example of an 8-bit overflow occurs in the binary sum 11111111 + 1 (denary: 255 + 1 = 256).

In binary, 11111111+00000001=100000000 but the leftmost 1 is an overflow number

The CPU cannot store the ninth bit and will assume the result is 0.

An animated explanation of binary overflow errors