16 bit Signed Integer...
With a signed integer the leading bit position is used as a sign indication with 1 being negative. The sign bit also is used as an indication that the magnitue bits are in 2's compliment.
Since the leading bit is used for the sign this leaves 15 bits for the number (32767).
Unsigned__Signed__Binary
0________0_______0000000000000000
32767____32767___0111111111111111
32768___-32767___1000000000000000
65535___-1_______1111111111111111
2's compliment:
This is a way to perform subtraction by adding... In a microcontroller it is easy to create circuits which invert bits, shift bit positions and add bits. A subtraction circuit is slower and a little more difficult to contstruct and is redundant if the same result can be performed with an adder circuit. (You can build a cheaper and faster microcontroller if you do not have to incorporate a subtraction circuit)
So to provide subtraction without a dedicated subtraction circuit the twos compliment is performed.
lets take 9 - 1 = 8 as a 4 bit example
in binary subtraction
1001
-0001
---------
1000
In 2's compliment you first invert(toggle) all of the bits into there opposite values ( 1 becomes 0 and 0 becomes 1), then add one.
0001 by inverting the bits becomes 1110, add a 1 and it will equal 1111.
1001 (9)
+1111 (2's compliment of 0001)
---------
11000
Notice the extra leading bit this is a carry and will be ignored if we were woring with a larger bit size the carry would be used in the next bit group. Since I was only doing a 4 bit example take the last 4 bits (ignoring the carry bit) and you will see the answer is 1000 (8) . You have just done the 9-1 subtratction by adding
9(1001) + 15(1111).
2007-05-28 04:14:57
·
answer #1
·
answered by MarkG 7
·
0⤊
0⤋
Negetive binary numbers are the 'two's complement' of positive numbers.
The 'two' means 2 steps to convert a positive number (as well as using base 2), and 'complement' means to reverse the number.
When you need to know if a number is signed, the most significant bit (MSB) of a byte, word, dword, etc., is the sign bit. If it is 1, then the number is negetive. To convert any number to it's two's complement form, you would use the NOT operator to reverse all the bits; All ones will become zero and all zeros become ones. Then you add 1.
(See the 2 step process?)
Example:
00000001 = 1
NOT
11111110 = FE
+1
11111111 = FF = -1
000000000 00000001 = 1
NOT
111111111 11111110 = FFFF FFFE
+1
111111111 11111111 = FFFF FFFF = -1
2007-05-28 02:51:28
·
answer #2
·
answered by Balk 6
·
0⤊
0⤋
16 bit binary of -1 is 1111111111111111 (the first bit is for sign and the rest is the complement)
compelments are used to make addition operation specially with binary negative numbers
take a look to this:
http://en.wikipedia.org/wiki/Method_of_complements
2007-05-28 02:32:38
·
answer #3
·
answered by khaaaalil 2
·
0⤊
0⤋
in hex it would be 0Fh but in binary it would too long to type.
approximately 1111 1111 1111 1111
2007-05-28 02:01:56
·
answer #4
·
answered by steven25t 7
·
0⤊
1⤋
FFFFFFFF FFFFFFFF
That's just a guess, I don't really know.
2007-05-28 01:55:50
·
answer #5
·
answered by Chie 5
·
0⤊
1⤋