What is the 6-bit signed binary value of the decimal number -31? Can someone show me how to do this. I know how to covert positive decimal value to binary, but I don't know how to do negative numbers. Would I just put a negative sign in front of the answer ?How do you convert negative decimal value to binary representation?
In computer systems, obviously putting a negative sign in front of it won't mean anything. Afterall, computers understand 0 and 1, not -.
In order to get around this little issue, number of encoding schemes were created. The one used in modern computers is called ';two's compliment';.
http://en.wikipedia.org/wiki/Two%27s_com鈥?/a>
in a 6 bit signed binary number using two's compliment:
1 1 1 1 1 1 = -1
1 1 1 1 1 0 = -2
1 1 1 1 0 1 = -3
1 1 1 1 0 0 = -4
1 1 1 0 1 1 = -5
1 1 1 0 1 0 = -6
... and so on
An easy way to quickly convert a postive binary number to a negative using two's compliment is to subtract one, then flip all the bits:
0 1 1 1 1 1 = 31
Substract 1: 0 1 1 1 1 0 = 30
Flip all the bits: 1 0 0 0 0 1 = -31
(NOTE: You can also flip all the bits then ADD 1.)How do you convert negative decimal value to binary representation?
Since binary is strictly 1's and 0's, we can not use a ';-'; sign in front of a binary number.
Generally, you find the 2's complement and add 1. (This might not be the right approach - it's been quite awhile since I've done this.)
Sometimes you invert the last bit to the left, and ignore it for anything other than the sign of the number.
No comments:
Post a Comment