levo

Data Types and Number Representation

Binary addition, subtraction and overflow

  • 3 things to know
  • Component 01

Overview

Recall questions on binary addition and carries, binary subtraction with borrows and by adding a two's complement, overflow and how to detect it for unsigned and two's complement numbers, and guarding against overflow.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What are the four rules for adding two binary digits in one column?

Key term

Add 11010110 and 01101001 in eight bits and say what happens at the left-hand end.

Key term

Add the eight-bit two's complement numbers 01000001 and 00011110 and decide whether overflow has occurred.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What are the four rules for adding two binary digits in one column?

    Model answer

    0 + 0 = 0. 0 + 1 = 1. 1 + 1 = 0 carry 1. And where a carry is already coming in, 1 + 1 + 1 = 1 carry 1. Work from the rightmost column leftwards, writing the carry into the next column to the left, exactly as in denary addition.

  2. 2

    Add the binary numbers 01011011 and 00101110, working column by column.

    Model answer

    The result is 10001001. Starting from the right: 1 + 0 = 1. 1 + 1 = 0 carry 1. 0 + 1 + 1 = 0 carry 1. 1 + 1 + 1 = 1 carry 1. 1 + 0 + 1 = 0 carry 1. 0 + 1 + 1 = 0 carry 1. 1 + 0 + 1 = 0 carry 1. 0 + 0 + 1 = 1. Checking in denary, the inputs are 91 and 46, and 91 + 46 = 137, which is 10001001.

  3. 3

    Add 11010110 and 01101001 in eight bits and say what happens at the left-hand end.

    Model answer

    The eight-bit result is 00111111 and there is a carry of 1 out of the leftmost column with nowhere to go. In denary the inputs are 214 and 105, whose true total is 319, but the largest an unsigned byte can hold is 255. The carry that is lost represents 256, and indeed 319 minus 256 is 63, which is 00111111. So the stored answer is wrong, and the lost carry out is the signal that it is wrong.

  4. 4

    What are the rules for borrowing in binary subtraction?

    Model answer

    0 minus 0 is 0, 1 minus 0 is 1, 1 minus 1 is 0, and 0 minus 1 needs a borrow. To borrow, take 1 from the next column to the left, which arrives in the current column as binary 10, that is 2, so the column becomes 10 minus 1 = 1. If the column you borrow from is a 0, it must borrow in turn from further left, and the chain continues until it reaches a 1.

  5. 5

    Subtract 01101110 from 10110100 using column subtraction with borrows.

    Model answer

    The answer is 01000110. Working from the right: 0 minus 0 = 0. 0 minus 1 needs a borrow, giving 1 with a borrow out. 1 minus 1 minus the borrow needs another borrow, giving 1. 0 minus 1 minus the borrow needs a borrow, giving 0. 1 minus 0 minus the borrow gives 0. 1 minus 1 gives 0. 0 minus 1 needs a borrow, giving 1. 1 minus 0 minus the borrow gives 0. In denary the sum is 180 minus 110 = 70, and 01000110 is 64 + 4 + 2 = 70.

  6. 6

    Do the same subtraction, 10110100 minus 01101110, by adding a two's complement instead, and comment on the final carry.

    Model answer

    The answer is again 01000110. Form the two's complement of 01101110 by flipping to get 10010001 and adding 1 to get 10010010. Now add 10110100 and 10010010, which gives 01000110 with a carry of 1 out of the leftmost column. That final carry is simply discarded; in two's complement subtraction it is expected and carries no information. The result 01000110 is 70, matching the column subtraction exactly.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

A0 + 0 gives 0.
B0 + 1 gives 1.
C1 + 1 gives 0 carry 1.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Data Types and Number Representation, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.