knowt logo

1.1.2 - Binary Addition and Subtraction

Aims

  • Show how to carry out binary addition on two binary numbers

  • Show how to carry out binary subtraction on two binary numbers

  • Be able to describe what is meant by the term overflow error and when they occur.

Binary Addition & Rules

Computers built from electronics combinations called “Logic Gates”

Most basic operation a computer processer can perform is adding values

Binary values input into processer and logic circuits determine the result

Denary - addition result can have a value and a carry when the result is too large (more than 9)

Working right to left:

1

1st, Add the units

2

6

2nd If > 9 Carry Tens

+

1

8

3rd Add Tens

=

4

4

when adding in Binary, the same rules applies but in Base-2

  1. 0+0=0

  2. 0+1=1

  3. 1+0=1

  4. 1+1=10 (Carry the 1)

  5. 1+1+1=11 (Carry the 1)

e.g.

0

0

1

1

1

1

1

0

0

0

1

1

1

0

1

+

1

0

0

1

1

0

1

1

=

1

0

1

1

1

0

0

0

Overflow Errors

Overflow is the 9th bit which occurs when the result of binary addition has a carry value on the far left column and nowhere to carry it to, making it too large for the number of bits the computer is working with

One’s and Two’s Complement

One’s and Two’s complements are used to represent negative binary numbers

One’s complement

To show negative binary numbers in one’s complements the bits need to be flipped (1’s to 0’s and vice versa) e.g -5 is 11010 and 5 00101

Becomes complex when used in arithmetic so Two’s complements is preferred

Two’s complement

For two’s complements, all bits are flipped and then 1 is added

  1. 7 in binary is 00000111

  2. bits are flipped 11111000

  3. then +1 - 11111001

Binary Subtraction

Two’s Complements

Convert number to be subtracted into negative two’s complements and then add together

To show a negative number in binary the sign (left most bit) becomes negative e.g. -128 (shown as 1)

the magnitude (other values) don’t show as negative

e.g. 1010101-0101100=0101001

1.Take the two binary numbers to be subtracted

1

0

1

0

1

0

1

0

1

0

1

1

0

0

  1. Find the two’s complement of the second binary number

1

0

1

0

1

0

1

0

1

0

1

1

0

0

1

0

1

0

1

0

0

  1. Add both binary numbers

    1

    0

    1

    0

    1

    0

    1

    0

    1

    0

    1

    1

    0

    0

    Convert

    1

    0

    1

    0

    1

    0

    0

    Add

    0

    1

    0

    1

    0

    0

    1

    1

    1

    1

Borrow Subtraction Method

When subtracting two numbers, borrow a 1 from the next column and it will add 2 to the column

e.g. 1010101-0101100

0

2

0

2

1

0

1

0

1

0

1

-

0

1

0

1

1

0

0

=

0

1

0

1

0

0

1

0-1= borrow a one from the next left column making the current column 2 becomes 2-1

1.1.2 - Binary Addition and Subtraction

Aims

  • Show how to carry out binary addition on two binary numbers

  • Show how to carry out binary subtraction on two binary numbers

  • Be able to describe what is meant by the term overflow error and when they occur.

Binary Addition & Rules

Computers built from electronics combinations called “Logic Gates”

Most basic operation a computer processer can perform is adding values

Binary values input into processer and logic circuits determine the result

Denary - addition result can have a value and a carry when the result is too large (more than 9)

Working right to left:

1

1st, Add the units

2

6

2nd If > 9 Carry Tens

+

1

8

3rd Add Tens

=

4

4

when adding in Binary, the same rules applies but in Base-2

  1. 0+0=0

  2. 0+1=1

  3. 1+0=1

  4. 1+1=10 (Carry the 1)

  5. 1+1+1=11 (Carry the 1)

e.g.

0

0

1

1

1

1

1

0

0

0

1

1

1

0

1

+

1

0

0

1

1

0

1

1

=

1

0

1

1

1

0

0

0

Overflow Errors

Overflow is the 9th bit which occurs when the result of binary addition has a carry value on the far left column and nowhere to carry it to, making it too large for the number of bits the computer is working with

One’s and Two’s Complement

One’s and Two’s complements are used to represent negative binary numbers

One’s complement

To show negative binary numbers in one’s complements the bits need to be flipped (1’s to 0’s and vice versa) e.g -5 is 11010 and 5 00101

Becomes complex when used in arithmetic so Two’s complements is preferred

Two’s complement

For two’s complements, all bits are flipped and then 1 is added

  1. 7 in binary is 00000111

  2. bits are flipped 11111000

  3. then +1 - 11111001

Binary Subtraction

Two’s Complements

Convert number to be subtracted into negative two’s complements and then add together

To show a negative number in binary the sign (left most bit) becomes negative e.g. -128 (shown as 1)

the magnitude (other values) don’t show as negative

e.g. 1010101-0101100=0101001

1.Take the two binary numbers to be subtracted

1

0

1

0

1

0

1

0

1

0

1

1

0

0

  1. Find the two’s complement of the second binary number

1

0

1

0

1

0

1

0

1

0

1

1

0

0

1

0

1

0

1

0

0

  1. Add both binary numbers

    1

    0

    1

    0

    1

    0

    1

    0

    1

    0

    1

    1

    0

    0

    Convert

    1

    0

    1

    0

    1

    0

    0

    Add

    0

    1

    0

    1

    0

    0

    1

    1

    1

    1

Borrow Subtraction Method

When subtracting two numbers, borrow a 1 from the next column and it will add 2 to the column

e.g. 1010101-0101100

0

2

0

2

1

0

1

0

1

0

1

-

0

1

0

1

1

0

0

=

0

1

0

1

0

0

1

0-1= borrow a one from the next left column making the current column 2 becomes 2-1

robot