Going from sign/magnitude of a hex value to it's two's complement

  • Thread starter leo255
  • Start date
  • Tags
    Value
The decimal value for 1011001010101 is 2475. In summary, the conversation discusses converting a hex number to two's complement in 13-bit and how the decimal value should be 2475. The poster shares their attempted solution and asks for help in understanding why their answer does not match the expected result. They also provide a link to a converter to verify their answer.
  • #1
leo255
57
2

Homework Statement



Hi all!

You are given the hex 9AB. I need to go from sign and magnitude of it, to it's two's complement (in 13-bit).

The Attempt at a Solution



What I did was convert the hex to binary:

0100110101011 <-- I added an extra 0 for the 13th bit

I then flipped the digits, and added "1" and got this:

1011001010101

The answer to this is supposed to be 2475, and I'm not getting that. Would appreciate any help anyone can give.

Thanks.
 
Physics news on Phys.org
  • #3
Your two's complement is correct.
 

1. How do you convert a positive hex value to its two's complement?

To convert a positive hex value to its two's complement, first determine the binary representation of the hex value. Then, invert all the bits and add 1 to the result. This will give you the two's complement representation of the original hex value.

2. What is the purpose of using two's complement in binary arithmetic?

The two's complement representation allows for the efficient representation of negative numbers in binary. This is important in binary arithmetic as it allows for the addition and subtraction of both positive and negative numbers using the same set of rules.

3. How do you convert a negative hex value to its two's complement?

To convert a negative hex value to its two's complement, first determine the binary representation of the hex value. Then, take the two's complement of the binary representation by inverting all the bits and adding 1 to the result. This will give you the original positive hex value.

4. Can you convert any hex value to its two's complement?

Yes, any hex value can be converted to its two's complement. However, the resulting two's complement representation may be different depending on the bit length of the binary representation. For example, a 4-bit binary representation can only represent values from -8 to 7, while an 8-bit binary representation can represent values from -128 to 127.

5. What happens if you try to convert a hex value with a leading 0 to its two's complement?

If a hex value has a leading 0, it is interpreted as a positive number and the two's complement representation will be the same as the original hex value. This is because the leading 0 indicates that the number is positive and does not require a two's complement conversion.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
950
Back
Top