Рет қаралды 2,581
Here we will try to understand Range of Negative Numbers in Different Representations.
Here is the discussion on how Negative Numbers or Signed Numbers are represented.
To have a better understanding we will consider a 4-bit number.
The image of the four-bit register is as shown below which has MSB for sign bit representation and remaining 3 bits for the magnitude of the number.
The table below shows the possible numbers with 4 bits.
In the above diagram, MSB is used for sign bit and the remaining three bits are used for the magnitude of the binary number.
Range of Negative Numbers in Different Representations
In the Sign Magnitude method, an additional bit called sign bit is placed in front of the number.
The magnitude of the number is represented in its true binary form.
If the sign bit is 0, the number is positive.
If the sign bit is 1, the number is negative.
The Range of numbers possible with four bits in sign-magnitude representation is from -7 to +7 as shown in the image below.
In sign-magnitude representation, 1 000 is used to represent -0 which is not desirable.
In 1's Complement Method, if the number is positive the magnitude is represented in its true binary form and the sign bit is placed with 0.
If the number is negative, the magnitude of the number is represented in its 1's complement form and the sign bit is placed with 1.
For example, 0 001 is the binary representation of 1 in 1's complement representation.
To represent -1 in 1's complement representation we have to take the 1's complement 001 and the sign bit has to be placed with 1.
The -1 is represented by 1 110.
The table below shows how 1 and -1 are represented in 1's complement representation.
Similarly, we can find the range of numbers represented in 1's complement method for 4 bits is as shown below.
In 1's complement representation, 1 111 is used to represent -0 which is not desirable.
In 2's Complement Method, if the number is positive the magnitude is represented in its true binary form and the sign bit is placed with 0.
If the number is negative, the magnitude of the number is represented in its 2's complement form and the sign bit is placed with 1.
For example, 0 001 is the binary representation of 1 in 2's complement representation.
To represent -1 in 2's complement representation we have to take the 2's complement 001 and the sign bit has to be placed with 1.
The -1 is represented by 1 111.
The table below shows how 1 and -1 are represented in 1's complement representation.
Similarly, we can find the range of numbers represented in 2's complement method for 4 bits is as shown below.
In 2's complement representation there is no separate representation for -0.
Whereas in sign-magnitude and 1's complement we have separate representation for -0.
In 2's complement, we have the representation for -8, this made the 2's complement representation to be widely used in modern computers.
The table below shows the range of numbers represented in Sign-magnitude, 1's Complement, and 2's Complement for 4-bits.
How to generalize the range for any bit size?
For sign-magnitude with 4-bits, the range is from - 24-1 -1 to 2 4-1 -1.
Which is from -7 to 7.
For 1's complement with 4-bits, the range is from - 24-1 -1 to 2 4-1 -1.
Which is from -7 to 7.
For sign-magnitude with 4-bits, the range is from - 24-1 to 2 4-1 -1.
Which is from -8 to 7.
The generalized range for n bit in sign-magnitude representation is - 2n-1 -1 to 2 n-1 -1.
The generalized range for n bit in 1's complement representation is - 2n-1 -1 to 2 n-1 -1.
The generalized range for n bit in 2's complement representation is - 2n-1 to 2 n-1 -1.
Link for playlists:
/ @learningmonkey
Link for our website: learningmonkey.in
Follow us on Facebook @ / learningmonkey
Follow us on Instagram @ / learningmonkey1
Follow us on Twitter @ / _learningmonkey
Mail us @ learningmonkey01@gmail.com