NEXT PAGE >
TEXT REPRESENTATION |
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
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
WHAT IS NEGATIVE NUMBER REPRESENTATION ?
Computers use various methods of representing negative numbers. The three methods of representing negative numbers discussed here are:
0 1 0 1 1 0 0 1 represents the numeric value of 89
- Sign and Magnitude
- One's Complement
- Two's Complement
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:
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
Sign and Magnitude works but it is not a very good method of representing negative numbers because:
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.
- 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:
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.
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.
One's complement is still inefficient because:
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.
- It creates two 0s : a positive 0 and a negative 0
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;
The rule to convert a number into its Two's complement representation are;
- Flip the bits
- Add 1
Two's complement is more efficient because:
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.
- 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:
To find the two's complement of -5 in an 8-bit system:
- Start with the binary representation of 5: 0000 0101.
- Invert the bits: 1111 1010.
- Add 1 to the result: 1111 1010 + 1 = 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.
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.
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?
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?
|
|
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)
☑ 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)