levo

Data Types and Number Representation

Negative numbers: sign and magnitude and two's complement

  • 2 things to know
  • Component 01
Start revising · £5/month

Overview

Recall questions on sign and magnitude and its two zeros, two's complement and the flip-and-add-one method, converting negative numbers both ways, ranges of each, subtracting with an adder, and sign extension.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is the range of an eight-bit sign and magnitude number?

Key term

Give three reasons why two's complement is preferred to sign and magnitude.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    In sign and magnitude, how is a negative number represented?

    Model answer

    The leftmost bit is used purely as a sign flag, 0 meaning positive and 1 meaning negative, and all the remaining bits hold the size of the number as an ordinary positive binary value. The sign bit has no place value of its own; it is just a label saying which way to read the magnitude.

  2. 2

    Write minus 37 as an eight-bit sign and magnitude number.

    Model answer

    10100101. The magnitude 37 in seven bits is 0100101, since 32 + 4 + 1 = 37. Putting a 1 in front as the sign bit to mark it negative gives 10100101.

  3. 3

    What is the range of an eight-bit sign and magnitude number?

    Model answer

    Minus 127 to plus 127. Seven bits are left for the magnitude, and the largest seven-bit value is 1111111, which is 127. The sign bit then allows that magnitude either way.

  4. 4

    What is the problem with zero in sign and magnitude?

    Model answer

    There are two representations of it. 00000000 is positive zero and 10000000 is negative zero, and they are the same number written two ways. This wastes a bit pattern, but worse, it means a test for zero has to check for two different patterns and a comparison of two values cannot simply compare their bit patterns, since the two zeros are equal in value but different in bits.

  5. 5

    Add the sign and magnitude numbers 00000101 and 10000011 as though they were plain binary, and explain what goes wrong.

    Model answer

    The two numbers are plus 5 and minus 3, so the answer should be plus 2. Adding the bit patterns column by column gives 10001000, which reads as sign 1 and magnitude 0001000, that is minus 8. It is nonsense. The problem is that in sign and magnitude the sign bit is not part of the number's value, so it must not be added in, and the hardware instead has to compare the two magnitudes, decide which to subtract from which, and then work out the sign of the result separately. That extra logic is the main reason the representation is not used for arithmetic.

  6. 6

    In two's complement, what is different about the leftmost bit?

    Model answer

    It is a genuine place value, but a negative one. In an eight-bit two's complement number the leftmost bit is worth minus 128, while all the other bits keep their normal positive place values of 64, 32, 16, 8, 4, 2 and 1. So the sign bit is part of the arithmetic rather than a separate flag, which is exactly why ordinary binary addition works on these numbers.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

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

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

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

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

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.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

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