Reputation: 51
So my professor has a question to make a list of all positive and negative numbers that can be represented in Ones', two's complements, and sign-magnitude:
Using 4-bit numbers, for example (5)10 = ( 0101)2 Write all positive numbers and all negative numbers that can be represented with four bits in sign-magnitude, ones' complement, and two’s complement.
Now, I am not looking for the answer just clarification.
can someone explain this question better?
Upvotes: 3
Views: 29817
Reputation: 1931
Here's a brief description about all the three representation techniques you've mentioned.
In this representation, we can represent numbers in any number of bits (powers of 2). There are two parts in the representation. Sign and Magnitude, as the name implies.
If we want to represent a number in n number of bits,
e.g. If you want to represent +25 and -25 using 8 bits: (+25)10 = 0011001 and (-25)10 = 10011001
Since Binary number system has only 2 digits (0 and 1), the complement of one digit is the other. i.e. the complement of 0 is 1 and vice versa.
In this representation, there is no specific bit to represent the sign, but the MSB (Most Significant Bit) can be used to determine the sign of the number. i.e. MSB is 0 if the number is positive and 1 if the number is negative. Binary numbers are used and also a specific bit size is used. (e.g. 8, 16, 32, etc. bits).
If the number is positive
If the number is negative
e.g. Take the previous example again
This representation technique is very much similar to One's Complement Representation. The main difference is that when the number is negative, 1 is added to the LSB (Least Significant Bit) after getting the complement.
e.g. Let us take the same example
Upvotes: 12