Computer ScienceChapter 1: Computer Systems
1.2.6 Signed and Unsigned Numbers Representation
Unsigned Numbers Representation:
Explanation level
Introduction
Binary numbers can be represented in signed and unsigned ways. Unsigned binary numbers do not have a sign bit, whereas signed binary numbers use a sign bit as well so that a distinction can be made between positive and negative numbers.
Definition
Unsigned Numbers Representation: Unsigned numbers don't have any sign; they can contain only the magnitude of the number. So, the representation of unsigned binary numbers includes all positive numbers only. For example, the representation of positive decimal numbers is positive by default. We always assume that there is a positive sign symbol in front of every number.
Signed Numbers Representation: Signed numbers can represent both positive and negative integers. There are several methods to represent signed numbers, but the most common one used in modern computers is Two's Complement.
Main Idea
- Unsigned: All bits are used for magnitude. Range: 0 to (2n - 1).
- Signed: One bit (the MSB) is used as the sign bit. The remaining bits represent the magnitude or value. Range (two's complement): -2n-1 to (2n-1 - 1).
Core Concept
Unsigned Numbers Representation
Unsigned numbers don't have any sign; these can contain only the magnitude of the number. So, the representation of unsigned binary numbers includes all positive numbers only. For example, the representation of positive decimal numbers is positive by default. We always assume that there is a positive sign symbol in front of every number.
The range of unsigned binary numbers is from 0 to (2n - 1), where n is the number of bits. For example, in 8-bit form, the range will be from 0 to 255 (decimal) and 00000000 to 11111111 (binary).
Example: Represent decimal number 105 in unsigned binary number.
Simply convert 105 into a binary number.
105 = (01101001)2
Signed Numbers Representation
Signed numbers can represent both positive and negative integers. There are several methods to represent signed numbers, but the most common one used in modern computers is Two's Complement.
Two's Complement Representation:
To get the 2's complement of a number, flip all the bits and then add 1 to the least significant bit (LSB). We use regular binary for positive numbers and 2's complement for negative numbers.
- If the sign bit is 0, the number is positive and we can just use its regular binary form.
- If the sign bit is 1, the number is negative, and we need to use the 2's complement of the binary number to get its value.
Detailed Explanation
Example 1: Represent -13 in a computer using 8-bit 2's complement
- Convert 13 to binary: 13 in 8-bit binary form is 00001101
- Invert all the bits: 11110010
- Add 1 to get 2's complement: 11110010 + 1 = 11110011
- So, -13 is represented as 11110011 using 2's Complement
Example 2: Represent -55 in a computer using 8-bit 2's complement
- Convert 55 to binary: 55 in 8-bit binary form is 00110111
- Invert all the bits: 11001000
- Add 1 to get 2's complement: 11001000 + 1 = 11001001
- So, -55 is represented as 11001001 using 2's Complement
Intermediate Level
At the intermediate level, you should understand the range and how to convert.
Unsigned 8-bit range: 0 to 255
Signed 8-bit range (two's complement): -128 to +127
General formulas for n bits:
Unsigned range: 0 to (2n - 1)
Signed range (two's complement): -2n-1 to (2n-1 - 1)
How to find the value of a negative signed number: If the MSB is 1, the number is negative. To find its magnitude, take the 2's complement of the number. The result is the positive magnitude.
Example: 11110011 → MSB is 1 → negative. 2's complement of 11110011 = 00001101 = 13. So 11110011 = -13.
Important Points
- - Unsigned numbers: no sign bit, only positive values.
- - Signed numbers: sign bit (MSB), both positive and negative values.
- - Two's complement is the standard for signed integers.
- - Unsigned 8-bit range: 0 to 255.
- - Signed 8-bit range: -128 to +127.
- - MSB = 0 → positive; MSB = 1 → negative (in two's complement).
- - To find the value of a negative number, take its 2's complement.
Remember
- - Unsigned: all bits used for magnitude.
- - Signed: MSB is the sign bit.
- - 8-bit unsigned: 0–255.
- - 8-bit signed: -128 to +127.
- - MSB = 0 → positive.
- - MSB = 1 → negative (two's complement).
- - To find magnitude of negative number: take 2's complement.
Common Mistakes
- - Forgetting that the MSB is the sign bit in signed representation.
- - Confusing the range of signed and unsigned numbers.
- - Thinking that 11111111 is always 255 (it is 255 unsigned but -1 signed).
- - Forgetting to take the 2's complement when finding the magnitude of a negative signed number.
- - Assuming that signed and unsigned numbers with the same bit pattern have the same value.
- - Mixing up the formulas for range.
Quick Revision
- Unsigned: all bits for magnitude; range 0 to 2n-1.
- Signed: MSB is sign bit; range -2n-1 to 2n-1-1.
- 8-bit unsigned: 0–255.
- 8-bit signed: -128 to +127.
- MSB = 0 → positive; MSB = 1 → negative.
- Two's complement is used for signed representation.
- To find the value of a negative number, take its 2's complement.
60-Second Revision
- Unsigned: no sign, all positive; range 0 to 2n-1.
- Signed: MSB is sign; range -2n-1 to 2n-1-1.
- 8-bit unsigned: 0–255; 8-bit signed: -128 to +127.
- MSB = 0 → positive; MSB = 1 → negative.
- To find magnitude of negative: take 2's complement.
- Warning: Same bit pattern means different values for signed and unsigned.
Did you understand this topic?
Your answer is saved with your learning record. It does not mark the topic as mastered.
Quick revision
Revision Zone
Review the key facts, formulas and checks before you move on.1.2.6 Signed and Unsigned Numbers Representation
Sticky Notes · Quick Revision
Key Point 1
- Unsigned: no sign bit.
Key Point 2
- Signed: MSB = sign bit.
Key Point 3
- 8-bit unsigned: 0–255.
Key Point 4
- 8-bit signed: -128 to +127.
Key Point 5
- MSB = 0 → positive.
Key Point 6
- MSB = 1 → negative.
Key Point 7
- To find magnitude: take 2's complement.
Same supplied content as this Notes page (shared canonical source).