Two's complement & signed binary

Computer Science · Data representation

Question 1 of 10

0

    What is the largest denary number that can be stored in 11-bit two's complement? Give your answer as a denary number.

    Decimals (0.75 or 0,75), fractions (3/4) and mixed numbers (1 1/2) are accepted. Do not use thousands separators.

    How to type your answer
    • Fractions: 3/4. Mixed numbers: 1 1/2.
    • Decimals with a point or a comma: 0.75 or 0,75.
    • Negative numbers start with a minus: -3/4.
    • Percentages need the % sign: 75%.

    Stuck? Read the explanation

    Unlocks at a streak of 5 correct answers in a row.

    Print a free worksheet (PDF)

    Embed this practice on your site or class page

    Paste this HTML into your page. Students practise right there; it is free and needs no account.

    Two's complement & signed binary explained

    Binary numbers can represent positive values, but computers also need negative numbers. Two's complement is the most common method. In an n-bit two's complement number, the leftmost bit is the sign bit: a 0 means the number is positive or zero, and a 1 means it is negative. The leftmost bit is given a negative place value, while the other bits keep their usual place values. Using two's complement means that addition works in the same way for positive and negative numbers.

    To find the two's complement form of a negative number, write the positive version in binary with the same number of bits, invert every bit (change 0s to 1s and 1s to 0s), and then add 1. To convert back, you can use the same steps again, or add up the place values with the sign bit counted as negative.

    The method also gives a fixed range. In 8 bits, the values run from -128 to 127. Adding two positive numbers so the result is too large for the bit pattern causes overflow, and the answer wraps around into a wrong negative value.

    Worked example

    Represent -25 as an 8-bit two's complement number.

    1. Write 25 in 8 bits: 00011001.
    2. Invert every bit: 11100110.
    3. Add 1: 11100111.
    4. Check: the place values give 128+64+32+4+2+1=231128 + 64 + 32 + 4 + 2 + 1 = 231, and 231−256=−25231 - 256 = -25.

    What you will practise

    New numbers every time you practise. Levels: Easy, Medium, Hard. Each answer is followed by a worked explanation.

    Example questions

    • Easy

      What is the largest denary number that can be stored in 12-bit two's complement? Give your answer as a denary number.

    • Medium

      A temperature sensor sends the 8-bit two's complement pattern 11001011. What denary value does it represent? Give your answer as a denary number (it is negative).

    • Hard

      Add the two 8-bit two's complement numbers 11011000 and 10001000. Any carry out of the left-hand bit is discarded. What denary value does the 8-bit result represent? Give your answer as a denary number.