Units and data representation - OCRBinary addition

All data is represented as binary digits, whether it is numbers, text, images or sound. Calculations are also done in binary.

Part ofComputer ScienceComputer systems

Binary addition

When two numbers are added together in , we take the first number, add the second number to it, and get an answer. For example, 1 + 2 = 3.

When we add two numbers together the process is different.

There are four rules that need to be followed when adding two binary numbers. These are:

  • 0 + 0 = 0
  • 1 + 0 = 1
  • 1 + 1 = 10 (binary for denary 2)
  • 1 + 1 + 1 = 11 (binary for denary 3)

Example - adding 01 + 10

1 + 0 = 1

0 + 1 = 1

Binary addition: 0 1 plus 1 0 equals 1 1

Result in binary: 11 (which is denary 3)

Example - adding 01 + 101

1 + 1 = 0, carry 1

1 + 0 + 0 = 1

0 + 1 = 1

Binary addition: 0 1 plus 1 0 1 equals 1 1 0

Result in binary: 110 (which is denary 6)

Example - adding 01010011 + 01110110

1 + 0 = 1

1 + 1 = 0, carry 1

1 + 0 + 1 = 0, carry 1

1 + 0 + 0 = 1

1 + 1 = 0, carry 1

1 + 0 + 1 = 0, carry 1

1 + 1 + 1 = 1, carry 1

1 + 0 + 0 = 1

Binary addition: 0 1 0 1 0 0 1 1 plus 0 1 1 1 0 1 1 0 equals 1 1 0 0 1 0 0 1

Result in binary: 11001001 (which is denary 201). You can check your answers by converting each binary number into denary and checking your addition. In this example, 01010011 is 83 in denary and 01110110 is 118 in denary. So, 83 + 118 is 201.

Overflow

Overflow errors occur when the result of a calculation requires more bits (place values) than are in the available range.

For example, when using eight bits, the largest number that can be recorded is 11111111 (denary 255). When adding together two eight-bit numbers, a situation may occur when the result requires more than eight bits to hold it. For example, adding the binary numbers 11111110 (denary 254) and 00000010 (denary 2) would give:

Binary addition: 1 1 1 1 1 1 1 0 plus 0 0 0 0 0 0 1 0 equals 0 0 0 0 0 0 0 0

The result is actually 10000000 (denary 256), which requires nine bits. However, as only eight bits are available to hold the number, the result would be 00000000 (denary 0).

As you can see, overflow can have serious consequences for the validity of calculations.