When two numbers are added together in denaryThe number system most commonly used by people. It contains 10 unique digits 0 to 9. Also known as decimal or base 10., we take the first number, add the second number to it, and get an answer. For example, 1 + 2 = 3.
When we add two binaryA number system that contains two symbols, 0 and 1. Also known as base 2. 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
Result in binary: 11 (which is denary 3)
Example - adding 01 + 101
1 + 1 = 0, carry 1
1 + 0 + 0 = 1
0 + 1 = 1
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
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:
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.