COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
HOME    >    GCSE    >   CAMBRIDGE EXAMINATIONS    >    NEGATIVE NUMBERS
NEXT PAGE >
TEXT REPRESENTATION 
Picture

DATA REPRESETATION - 1.1.6 | TWO'S COMPLEMENT

OBJECTIVES
1.1.6 Use two’s complement to represent positive and negative 8-bit binary integers
  • Convert a positive binary or denary integer to a two’s complement 8-bit integer and vice versa
  • Convert a negative binary or denary integer to a two’s complement 8-bit integer and vice versa
  • LEARN
  • TERMINOLOGY
  • QUESTIONS
  • FLASHCARDS
  • WORKBOOK
<
>
Picture

we’re going to dive into three ways to represent positive and negative numbers in binary: Sign and Magnitude, One’s Complement, and Two’s Complement. Let’s break down each method and see how they work. Part 1: Sign and Magnitude Let’s start with Sign and Magnitude. This is one of the simplest ways to represent positive and negative numbers in binary. Here’s how it works: In Sign and Magnitude, we use the leftmost bit – known as the sign bit – to indicate whether the number is positive or negative: If the sign bit is 0, the number is positive. If the sign bit is 1, the number is negative. The remaining bits represent the actual value, or magnitude. For example: In an 8-bit system, the binary number 0000 1010 has a sign bit of 0, meaning it’s positive. The remaining bits, 0000 1010, represent the number 10 in decimal. Now, if we change that sign bit to 1, making it 1000 1010, the number becomes -10 in decimal. The rest of the bits stay the same, representing the value. However, Sign and Magnitude has limitations because it can make binary arithmetic more complex, especially when dealing with subtraction. Part 2: One’s Complement Next, we have One’s Complement. This method also uses the leftmost bit as a sign bit, but it represents negative numbers differently. Here’s the rule for One’s Complement: To find the One’s Complement of a binary number, invert all the bits – that means changing 0s to 1s and 1s to 0s. For example: If we want to represent -10 in an 8-bit system: Start with the positive binary representation of 10, which is 0000 1010. Invert each bit to get the One’s Complement: 1111 0101. So, 1111 0101 represents -10 in One’s Complement. One’s Complement simplifies some operations, but there’s a problem: it has two representations of zero. 0000 0000 represents positive zero, and 1111 1111 represents negative zero, which can make arithmetic operations tricky. Part 3: Two’s Complement Finally, let’s look at Two’s Complement. This is the most widely used method because it solves the issue of having two zeros and makes binary arithmetic easier. Here’s how to find the Two’s Complement of a number: Start with the positive version of the number in binary. Invert all the bits to get the One’s Complement. Add 1 to the result. For example: Let’s represent -10 in Two’s Complement. Start with the positive version of 10 in binary: 0000 1010. Invert all the bits to get 1111 0101. Add 1 to the inverted result: 1111 0101 + 1 = 1111 0110. So, 1111 0110 represents -10 in Two’s Complement. Two’s Complement only has one representation of zero, which is 0000 0000. It also makes addition and subtraction much simpler for computers because they can treat both positive and negative numbers the same way during calculations. Part 4: Summary To recap: Sign and Magnitude uses a sign bit to indicate positive or negative, but it can make arithmetic tricky. One’s Complement inverts all the bits to represent negative numbers, but it has two zeros. Two’s Complement inverts all the bits and adds 1, making binary arithmetic easier and solving the two-zero issue. And that’s it! These three methods – Sign and Magnitude, One’s Complement, and Two’s Complement – are fundamental to understanding how computers represent both positive and negative numbers in binary. Thanks for listening, and I hope this explanation helps you see how each method works!

Read Aloud
■
WHAT IS NEGATIVE NUMBER REPRESENTATION ?
Computers use various methods of representing negative numbers. The three methods of representing negative numbers discussed here are:
  • Sign and Magnitude
  • One's Complement
  • Two's Complement
A normal binary number that has had no change made to it would be referred to as 'unsigned binary' , so if an exam question gives a binary number and stipulates that it is unsigned then it is a simple straight forward binary number. (As was represented on the binary page of this website), for example:

0 1 0 1 1 0 0 1 represents the numeric value of 89
SIGN AND MAGNITUDE
Sign and magnitude is a simple method of representing negative. It simply takes the most significant BIT (the left hand bit) of a binary value and uses it to represent if the number is positive or negative.

The rule of Sign and Magnitude is:
  • The most significant bit represents if it is positive or negative(0 = positive, 1 = negative)
  • The remaining bits represent the value of the number
As can be seen in the table below.
Picture
Sign and Magnitude works but it is not a very good method of representing negative numbers because:
  • It creates two 0s : A positive 0 and a negative 0
  • It creates hardware problems in the processing of these numbers

If you have an exam question that say the number given is already in Sign and Magnitude representation then you need to answer accordingly.

Question: If 10001101 is already in its Sign and Magnitude representation then what would the denary value be?
Answer: -13 :Because the most significant bit is 1 so we know it is a negative number and then the remaining bits add up to 13 therefore the answer is negative -13.
​ONES COMPLEMENT
One's complement is another method of representing negative numbers. Computer hardware can process One's Complement numbers better than those represented in Sign and Magnitude however, one's complement still produces two 0s.

The rule of One's complement is:
  • Take the positive value and flip the bits to create the complement.

So for example, take 0 0 1 which represents the denary value of 1, flip the bits (change the 0s to 1s and 1s to 0s), this gives you 1 1 0 which in One's Complement represents negative  -1 . Again the positive values will always be represented with 0 being the most significant bit.
As can be seen in the table below.
Picture
One's complement is still inefficient because:
  • It creates two 0s : a positive 0 and a negative 0
If you have an exam question that say the number given is already in One's Complement representation then you need to answer accordingly.

Question: If 10001101 is already in its One's Complement representation then what would the denary value be?
Answer: -114 :By flipping the bits back to their original value we get 01110010 which is 114 therefore -114 is the complement.
TWOS COMPLEMENT
Two's Complement is another way of representing negative numbers in binary and it is less problematic than Sign and Magnitude or One's Complement.

The rule to convert a number into its Two's complement representation are;
  • Flip the bits
  • Add 1
As can be seen in the table below, if we flip the BITs(same as in One's Complement) then add 1 to the flipped result, the answer represents the Two's complement value.
Picture
Two's complement is more efficient because:
  • It only produces one Zero
  • It does not create hardware problems in processing

If you have an exam question that say the number given is already in Two's Complement representation then you need to answer accordingly.

Question: If 10001101 is already in its Two's Complement representation then what would the denary value be?
Answer: -115 :Because (working in reverse) if we take 01110011 (115) flip the bits it gives us 10001100, add 1 to this value give us 10001101. So the answer is negative -115.
CHECK YOUR KNOWLEDGE

What is the two's complement representation of -5 in an 8-bit binary system?

A) 1111 1011
B) 1111 1101
C) 1000 0101
D) 1111 1001
EXPLAINATION
The correct answer is A) 1111 1011.
To find the two's complement of -5 in an 8-bit system:
  1. Start with the binary representation of 5: 0000 0101.
  2. Invert the bits: 1111 1010.
  3. Add 1 to the result: 1111 1010 + 1 = 1111 1011.
So, the two's complement representation of -5 is 1111 1011.
.
Binary | A base-2 number system used in computing, consisting only of the digits 0 and 1.
Bit | The smallest unit of data in computing, represented as either 0 or 1.
Sign and Magnitude | A method of representing positive and negative numbers in binary. The leftmost bit (sign bit) represents the sign, where 0 indicates a positive number and 1 indicates a negative number.
One’s Complement | A binary method of representing negative numbers. To find the one’s complement of a binary number, invert all bits (change 0s to 1s and 1s to 0s).
Two’s Complement | A method used in binary to represent positive and negative integers. To get the two’s complement of a number, invert all bits (find the one’s complement) and then add 1 to the result. This system is widely used because it simplifies binary arithmetic.
Sign Bit | The leftmost bit in a binary number that indicates the number’s sign. In sign and magnitude, a 0 in this bit represents a positive number, and a 1 represents a negative number.
Magnitude | The part of a binary number that represents the actual value, without considering the sign bit.
Invert | To change each bit in a binary number to its opposite: 0 becomes 1, and 1 becomes 0.
Overflow | An error that occurs when a binary operation produces a result that exceeds the range that can be represented within the allocated number of bits.
Binary Addition | The process of adding binary numbers. It follows specific rules and is foundational to operations in two’s complement.
8-bit System | A binary representation limited to 8 bits, allowing values from -128 to 127 in two’s complement form.
Unsigned Integer | A binary number that represents only positive values, with no sign bit.
Complement | A method of obtaining the inverse or opposite value of a binary number. In one’s complement, all bits are inverted, and in two’s complement, 1 is added to the inverted bits.
Picture
1: What is the purpose of sign and magnitude, one's complement and two's complement methods?
2: What are the rules for sign and magnitude?
3: What are the limitations for the sign and magnitude method?
4: Using sign and magnitude what is negative representation for -55? (show your workings)
5: What are the rules for one's complement?
6: What are the limitations for the one's complement?
7: Using one's complement what is negative representation for -55? (show your workings)
8: What are the rules for two's?

9: Using two's complement what is negative representation for -55? (show your workings)
10: If the value 10101000 is already in two's complement, what is the Denary value represented?
Picture
NEXT PAGE | TEXT REPRESENTATION
1.1 NUMBER SYSTEMS
   
☑ 1.1.1 WHY COMPUTERS USE BINARY
    ☑ 1.1.2 BINARY, HEX AND CONVERTIG BETWEEN NUMBER SYSTEMS
    ☑ 1.1.3 BENEFITS OF HEX
    ☑ 1.1.4 BINARY ADDITION AND OVERFLOW
    ☑ 1.1.5 BINARY SHIFTS
    ➩  1.1.6 NEGATIVE NUMBER REPRESENTATION, TWO'S COMPLEMENT
1.2 COLOUR AND SOUND

    ☐ 1.2.1 HOW COMPUTERS REPRESENT TEXT
    ☐ 1.2.2 HOW COMPUTERS REPRESENT SOUND
    ☐ 1.2.3 HOW COMPUTERS REPRESENT IMAGES
1.3 FILE SIZE AND COMPRESSION

    ☐ 1.3.1 HOW STORAGE IS MEASURED
    
☐ ​1.3.2 CALCULATING IMAGE AND SOUND FILE SIZE
   
☐ ​1.3.3 PURPOSE OF COMPRESSION
   
☐ ​1.3.4 LOSSY AND LOSSLESS COMPRESSION
 EXTRAS

    ☐ END OF TOPIC REVIEW | COMING SOON
    
☐ TOPIC 1 KEY TERMINOLOGY
    
☐ REVISION FLIP CARDS
    
☐ TOPIC 1 ANSWERS
    
☐ TOPIC 1 TEACHER RESOURCES (CIE)
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.