# 9. Binary arithmetic operations - Addition

Post date: 01-Jul-2014 05:02:26

## Binary arithmetic operations - Addition, Complimentation and shifting

### Representation of signed binary numbers

There are three ways of representing a signed binary number (positive or negative).

1. Prefixing an extra sign bit to a binary number
2. Using ones compliment
3. Using two's compliment

Prefixing an extra sign bit to a binary number

In decimal numbers a sign bit for example: can be represented as ‘-1’ or ‘+1’ for negative and positive respectively. However in binary numbers, “1” and “0” are added as an extra bit on the left of a binary number to denote negative and positive numbers respectively. For example: ASCII is a 7-bit coding scheme, a number like 110 can be represented as 00000012 to show whether it’s a negative we add a “1” to the left of the binary digit thus: (1)00000012 and to show whether it’s a positive a “0” is added to the leftmost digit thus: (0)0000001. The problem of using this method is that 010 can be represented in two ways thus: (0)0000000and (0)0000000

Ones Compliment

The term complement refers to a part which together with another makes up a whole. For example: in geometry, two complimentary angles add up to one right angle (900). Compliments are used to address the problem of signed numbers for instance; positive and negative numbers.

In decimal numbers (0-9), we talk of nine’s compliment. E.g. the nines compliment of 9 is 0, and that of 5 is 4 while that of 8 is 1. However, in binary numbers, the ones complement is the bitwise NOT applied to the number, Bitwise NOT is a unary operator (operates on only one operand) and performs logical negation on each bit. For example the bitwise NOT of 11002 is 00112 i.e. 0s are negated to 1s while 1s are negated to 0s. Likewise the bitwise NOT of 001011012 is 110100102 which represents -4510 Looking at the two numbers, the most significant digit shows that the number has a sign bit “0” for “+0” and “1” for “-0”. Like the method of using an extra sign bit, in ones complement, there are two ways of representing a zero.

Twos compliment

Twos compliment, equivalent to tens compliment in decimal numbers, is the most popular way of representing negative numbers n computer systems.

1. There are no two ways of representing a zero as is the case with the other two methods.

2. Effective addition and subtraction can be done even with numbers that are represented with a sign bit without a need for extra circuitry to examine the sign of an operand.

The twos’ compliment of a number is obtained by getting the ones compliment then adding a 1. For example, to get the twos complement of a decimal number 4510 first convert it to its binary equivalent then find its ones compliment. Add a 1 to the ones complement. Example:

4510 = 001011012

NOT (00101101) = 11010010

Twos’ complement = 110100102 + 12

= 110100112

The five possible additions in binary are:

1. 02+02=02

2. 02+12=12

3. 12+02=12

4. 12+12=102

5. 12+12+12=112

The following examples explain binary addition.

## Trial Questions

1. 10102 + 1112 =

2. 11112 + 1112 =

3. 10112 + 11102 =

4. 111012 + 101102 =

5. 10001112 + 100102 =

6. 11012 + 1012 + 112 =

7. 1111102 + 1112 + 102 =

8. 1000112 + 101012 + 1112 =

9. 1011102 + 11112 + 112 =

10. 11111112 + 1111112 + 11012

11. 1001012 + 110112 + 10112 =

12. 1100102 + 1110112 + 11002 =

13. 10002 + 11102 =

14. 1112 + 1002 =

15. 111112 + 111112 =