The range of 8-bit 2's complement numbers is from -128 to 127.
What is 2's Complement?
Two's complement is a method used to represent signed integers (positive and negative numbers) in binary format. It is the most common method for representing signed integers on computers today. The most significant bit (the leftmost bit) is used as the sign bit: a 0 indicates a positive number, and a 1 indicates a negative number [1.1, 1.2].
The remaining bits represent the magnitude of the number. The range of a 2's complement number is not symmetric. For an n-bit system, the range is from −(2n−1)negative open paren 2 raised to the n minus 1 power close paren
−(2𝑛−1)
to (2n−1−1)open paren 2 raised to the n minus 1 power minus 1 close paren
(2𝑛−1−1)
[1.2].
Calculating the Range for an 8-bit Number
For an 8-bit system, the number of bits (nn
𝑛
) is 8.
-
The minimum value is calculated as −(2n−1)negative open paren 2 raised to the n minus 1 power close paren
−(2𝑛−1)
:−(28−1)=−(27)=-128negative open paren 2 raised to the 8 minus 1 power close paren equals negative open paren 2 to the seventh power close paren equals negative 128
−(28−1)=−(27)=−128
-
The maximum value is calculated as (2n−1−1)open paren 2 raised to the n minus 1 power minus 1 close paren
(2𝑛−1−1)
:(28−1−1)=(27−1)=127open paren 2 raised to the 8 minus 1 power minus 1 close paren equals open paren 2 to the seventh power minus 1 close paren equals 127
(28−1−1)=(27−1)=127
This gives a range of numbers from -128 to 127, for a total of 256 unique values (28=2562 to the eighth power equals 256
28=256
) [1.2, 1.3].
Representing Numbers in 8-bit 2's Complement
-
Positive numbers: These are represented in a straightforward binary format. The sign bit is 0.
- For example, 5 is represented as 0000 0101.
- The largest positive number is 127, which is 0111 1111.
-
Negative numbers: To find the 2's complement representation of a negative number, you follow these steps:
- Take the binary representation of the positive version of the number.
- Invert all the bits (change 0s to 1s and 1s to 0s). This is called the 1's complement.
- Add 1 to the result [1.1].
- For example, to find the representation of -5:
- Positive 5 in binary is 0000 0101.
- Invert the bits: 1111 1010.
- Add 1: 1111 1011. This is the 2's complement representation of -5.
-
The most negative number, -128, is represented as 1000 0000 [1.1].
Advantages of 2's Complement
The 2's complement system has several advantages that make it standard in computing:
- Single representation for zero: Unlike other systems like sign-magnitude, 2's complement has only one representation for zero (0000 0000), which simplifies logic and arithmetic operations.
- Simplified arithmetic: Addition and subtraction can be performed using the same hardware logic regardless of whether the numbers are positive or negative, which simplifies the design of the Arithmetic Logic Unit (ALU) in a processor. For example, subtracting a number is the same as adding its 2's complement [1.1].
- Wider negative range: It allows for one extra negative number compared to positive numbers, which can be useful in certain applications [1.2].
Show all