Two's complement, where the left bit is worth a negative number, and subtraction by adding. Needed for Edexcel 1CP2 and for A-level.
What you will learn
- Convert between denary and two's complement
- Give the range of n-bit two's complement
- Subtract by adding a two's complement number
- Carry out an arithmetic right shift
- Explain the limits of a fixed number of bits
Two's complement
In two's complement, the left bit is worth a negative amount.
In 8 bits it is worth −128; the others are worth +64 down to +1 as usual.
- 1111 0110 = −128 + 64 + 32 + 16 + 4 + 2 = −10.
- A negative number always starts with 1; a positive one with 0.
- 8 bits store −128 to +127. In general, n bits store −2^(n − 1) to 2^(n − 1) − 1.
The rest of this lesson and its 10 practice questions are locked.
In this lesson
- Two's complement
- Making a number negative
- Shifts and limits
- Try it: Read a negative number
10 practice questions, marked as you go; about 20 minutes in all.
Key terms
Two's complement, Negative, Subtracting, Arithmetic right shift
In this unit: Data representation
Binary, denary and hexadecimal, binary addition and shifts, two's complement, and how characters, images and sound are stored and compressed.
- Binary, denary and hexadecimal
- Binary addition and shifts
- Negative numbers in binary
- Characters and images
- Sound and compression