signed binary number question

Thread Starter

Ramiel

Joined Feb 19, 2018
74
Guys why is the signed magnitude for positive binary numbers equal to 1'complement and 2'complement. for example if a number's signed magnitude was 0110 which is +7, why is the signed 1's complement not 0001. isnt with 1's complement we invert the numbers from 0's to 1's and vice versa.
like for negative number it is true for example if a signed magnitude was 1110 for -6 the signed 1's complement for it would be 1001. why does the rule apply only for negative numbers. here is a table that explains what i am talking abt.
 

Attachments

WBahn

Joined Mar 31, 2012
30,060
Signed Magnitude, 1's Complement, and 2's Complement are simply three different ways to represent signed integers using a binary system. Each method has advantages and disadvantages.

Signed Magnitude is the method that is closest to how humans represent signed integers with pen and paper. It's easy for us to understand, but performing arithmetic operations is quite complicated -- as it is for humans, but we've internalized how to do it so well that we don't even think about all the decisions and manipulations involved in just adding two signed numbers together.

One's Complement is easier for hardware to use and is easy to invert (take the negative) of a number (though not as easy as Signed Magnitude), but there are still tweaks that have to be built into the algorithms to get the correct answer.

Two's Complement allows us to use the same hardware that we do for performing arithmetic on unsigned integers with very little modification, but it requires more effort to simply take the negative of a number.

There's yet another representation for signed integers known as Offset Binary, or Excess-N.
 

Thread Starter

Ramiel

Joined Feb 19, 2018
74
Signed Magnitude, 1's Complement, and 2's Complement are simply three different ways to represent signed integers using a binary system. Each method has advantages and disadvantages.

Signed Magnitude is the method that is closest to how humans represent signed integers with pen and paper. It's easy for us to understand, but performing arithmetic operations is quite complicated -- as it is for humans, but we've internalized how to do it so well that we don't even think about all the decisions and manipulations involved in just adding two signed numbers together.

One's Complement is easier for hardware to use and is easy to invert (take the negative) of a number (though not as easy as Signed Magnitude), but there are still tweaks that have to be built into the algorithms to get the correct answer.

Two's Complement allows us to use the same hardware that we do for performing arithmetic on unsigned integers with very little modification, but it requires more effort to simply take the negative of a number.

There's yet another representation for signed integers known as Offset Binary, or Excess-N.
I am not quite sure this answered my question :/
 

MrChips

Joined Oct 2, 2009
30,808
You are misinterpreting the table.
The 1's complement of 0110 is 1001, This has nothing to do with the sign representation of the number.

When you start talking about signed numbers, you have to identify whether the number is positive or negative.

The complement of +7 is -7.
The complement of -7 is +7.

Now if we asked, what is the signed complement of 7, are we asking what is the representation of -7?

The proper question ought to be, what is the representation of +7 and -7 in 2's complement notation.
Or, what is the representation of +7 and -7 in 1's complement notation?
Or, what is the representation of +7 and -7 in signed complement notation?

What was the question again?
 

WBahn

Joined Mar 31, 2012
30,060
I am not quite sure this answered my question :/
Not really sure just what your question is.

So let's take a closer look at your original post.

Guys why is the signed magnitude for positive binary numbers equal to 1'complement and 2'complement.
This is because it is desirable for a number that is representable in two different representations to have the same representation. It's not a requirement, but it is highly desirable. Since you are using a 4-bit representation, let's stick with that. For unsigned integers (using straight binary), we can represent 0 through 15. In 1's complement we can represent -7 to +7 (with two representations for zero) and in 2's complement we can represent -8 to +7. In Signed Magnitude, we can represent -7 to +7 (again with two representations for zero). All three of these can represent the values 0 through 7, so we use the same representation for each of these eight values in all four systems.

for example if a number's signed magnitude was 0110 which is +7,
This isn't +7 in any of these systems. The value +7 in all four systems is 0111.

why is the signed 1's complement not 0001.
Why would it be? Even if the representation WAS 0110, why would the 1's complement be 0001?

isnt with 1's complement we invert the numbers from 0's to 1's and vice versa.
Yes. So the 1's complement of +7 (0111) would be 1000 (which is the representation for -7).

like for negative number it is true for example if a signed magnitude was 1110 for -6 the signed 1's complement for it would be 1001. why does the rule apply only for negative numbers. here is a table that explains what i am talking abt.
Where are you getting that if you invert the 0's to 1's and vice versa that 1110 would become 1001? You have three 1's followed by a zero. Inverting all of them will give you three 0's followed by a 1, or 0001. Notice that, in 1's complement, 1110 is -1 and 0001 is +1.

The pattern 1110 represents -6 in Signed Binary. Signed Binary is NOT 1's complement. It is a completely different way of representing signed integers.

In Signed Binary you reserve the leftmost bit for the sign bit. You then encode the magnitude in the remaining bits and use the sign bit to indicate whether it is positive or negative. So to take the additive inverse on ANY number represented in Signed Binary, you simply invert the leftmost bit. That's why there are two representations for zero, namely 0000 and 1000.

In 1's complement the additive inverse of ANY number is obtained by flipping ALL the bits. That's why there are two representations for zero, namely 0000 and 1111.

In 2's complement, the additive inverse of ANY number is obtained by subtracting the n-bit 2's complement representation from 2^n. So if you want the 2's complement representation for -7, you subtract 0111 (7) from 10000 (16) to get 1001 (-7). To get the additive inverse of -7, you do the same thing -- subtract 1001 (-7) from 10000 (16) to get 0111 (7).
 

Thread Starter

Ramiel

Joined Feb 19, 2018
74
Not really sure just what your question is.

So let's take a closer look at your original post.



This is because it is desirable for a number that is representable in two different representations to have the same representation. It's not a requirement, but it is highly desirable. Since you are using a 4-bit representation, let's stick with that. For unsigned integers (using straight binary), we can represent 0 through 15. In 1's complement we can represent -7 to +7 (with two representations for zero) and in 2's complement we can represent -8 to +7. In Signed Magnitude, we can represent -7 to +7 (again with two representations for zero). All three of these can represent the values 0 through 7, so we use the same representation for each of these eight values in all four systems.



This isn't +7 in any of these systems. The value +7 in all four systems is 0111.



Why would it be? Even if the representation WAS 0110, why would the 1's complement be 0001?



Yes. So the 1's complement of +7 (0111) would be 1000 (which is the representation for -7).



Where are you getting that if you invert the 0's to 1's and vice versa that 1110 would become 1001? You have three 1's followed by a zero. Inverting all of them will give you three 0's followed by a 1, or 0001. Notice that, in 1's complement, 1110 is -1 and 0001 is +1.

The pattern 1110 represents -6 in Signed Binary. Signed Binary is NOT 1's complement. It is a completely different way of representing signed integers.

In Signed Binary you reserve the leftmost bit for the sign bit. You then encode the magnitude in the remaining bits and use the sign bit to indicate whether it is positive or negative. So to take the additive inverse on ANY number represented in Signed Binary, you simply invert the leftmost bit. That's why there are two representations for zero, namely 0000 and 1000.

In 1's complement the additive inverse of ANY number is obtained by flipping ALL the bits. That's why there are two representations for zero, namely 0000 and 1111.

In 2's complement, the additive inverse of ANY number is obtained by subtracting the n-bit 2's complement representation from 2^n. So if you want the 2's complement representation for -7, you subtract 0111 (7) from 10000 (16) to get 1001 (-7). To get the additive inverse of -7, you do the same thing -- subtract 1001 (-7) from 10000 (16) to get 0111 (7).
Yeah i am sorry i messed up when i asked. My confusion is: +7 is 0111 and the signed 1’s complement of +7(0111) is also 0111 but the rule is that you invert all binary number so why is +7’s signed 1’s complement not 1000
 

MrChips

Joined Oct 2, 2009
30,808
Yeah i am sorry i messed up when i asked. My confusion is: +7 is 0111 and the signed 1’s complement of +7(0111) is also 0111 but the rule is that you invert all binary number so why is +7’s signed 1’s complement not 1000
Here we go again.
The problem is in how you word the question.

The complement of +7 is -7.
The complement of 0111 is 1000.

What is +7 in 1's complement representation? The answer is 0111.
What is +7 in 2's complement's representation? The answer is 0111.
What is +7 in signed magnitude representation? The answer is 0111.

What is -7 in 1's complement representation? The answer is 1000.
What is -7 in 2's complement's representation? The answer is 1001.
What is -7 in signed magnitude representation? The answer is 1111.

1's complement or 2's complement representation is just that, the name of the representation. It doesn't mean that you have to complement the bits.

You apply the complement rule when you want to find the complement of the number, i.e. when you want to convert the number from positive to negative, or negative to positive.

For example, what is the complement of 1111? The answer is 0000.
What is the complement of -1? The answer is +1.
What is the 2's complement representation of -1? The answer is 1111.

What is the 2's complement of -7?
What is the 1's complement of -7?
Answer: I am not going to go down either rabbit hole.
 

Thread Starter

Ramiel

Joined Feb 19, 2018
74
Here we go again.
The problem is in how you word the question.

The complement of +7 is -7.
The complement of 0111 is 1000.

What is +7 in 1's complement representation? The answer is 0111.
What is +7 in 2's complement's representation? The answer is 0111.
What is +7 in signed magnitude representation? The answer is 0111.

What is -7 in 1's complement representation? The answer is 1000.
What is -7 in 2's complement's representation? The answer is 1001.
What is -7 in signed magnitude representation? The answer is 1111.

1's complement or 2's complement representation is just that, the name of the representation. It doesn't mean that you have to complement the bits.

You apply the complement rule when you want to find the complement of the number, i.e. when you want to convert the number from positive to negative, or negative to positive.

For example, what is the complement of 1111? The answer is 0000.
What is the complement of -1? The answer is +1.
What is the 2's complement representation of -1? The answer is 1111.

What is the 2's complement of -7?
What is the 1's complement of -7?
Answer: I am not going to go down either rabbit hole.
Yeah thank you I kind of got what you mean but it is still kind of ambiguous and weird. I just need to get used to it. I am still in my second week of electrical eng and I have never had past experience with such stuff.
 

Thread Starter

Ramiel

Joined Feb 19, 2018
74
I really appreciate the fact that you are spending time to explain such stuff which is hard for me but like beginner and easy stuff for tou
 

MrChips

Joined Oct 2, 2009
30,808
There is nothing ambiguous or weird about it.
In the table that you posted in your opening post, the titles of the columns should have read :
Signed-1's Complement Representation
Signed-2's Complement Representation
Signed Magnitude Representation

The fact that the word "Representation" has been omitted is perfectly understandable and acceptable.

If there is any ambiguity, this one is, as an example:
What is the Signed-2's Complement of -7?
The complement of -7 is +7.
The complement of 1001 is 0110.

Hence to ask the question, what is the signed-2's complement of -7,
is the answer 0111 or 1001?

The ambiguity is in the question, not in the answer.
 

WBahn

Joined Mar 31, 2012
30,060
Yeah i am sorry i messed up when i asked. My confusion is: +7 is 0111 and the signed 1’s complement of +7(0111) is also 0111 but the rule is that you invert all binary number so why is +7’s signed 1’s complement not 1000
I think you might be confusing a couple of things.

When someone says to "take" the 1's complement of a number, they generally mean to find the 1's complement representation of the additive inverse of that number.

But another thing that can be asked is what is the 1'complement representation of a number, in which case the want how you represent that number (NOT it's additive inverse) in 1's complement.

However, if you just ask what is the 1's complement of a number, it can be interpreted either way. Usually, the context of the question makes it fairly clear which interpretation was meant. But that's not always the case.

So the 4-bit 1's complement representation of +7 is 0111 and the 4-bit 1's complement representation of it's additive inverse is 1000.
 
Top