it dont get it, is it a software thing?Graceofgod said:Its bump time, oh well, hopefully this helps someone.
13 = 01101
-13 (2's comp) = 10011
7 = 00111
-7 (2's comp) = 11001
-13 + -7
10011
11001+
01100 (2's comp) (cutting off the extra 1)
= 10100 (normal) = 20
Therefore answer is -20
Well, I guess that would explain why it is in Software Design and Development.Zippora said:it dont get it, is it a software thing?
so i get how = 10100 is 20 but how does it know its minus 20 ?Graceofgod said:Its bump time, oh well, hopefully this helps someone.
10011
11001+
01100 (2's comp) (cutting off the extra 1)
= 10100 (normal) = 20
Therefore answer is -20
Well when you change it from 2's complement it equals 20.crammy90 said:so i get how = 10100 is 20 but how does it know its minus 20 ?
i think i get it now..so if it has a leading 1 in 2's comp when we put it back into normal form its negative whatever that number is, if it has a leading 0 in 2's comp when we put it into normal it is positive whatever the number is?Graceofgod said:Ok, using 8 bits (to make it much clearer hopefully):
13 = 00001101
-13 (2's comp) = 11110011
7 = 00000111
-7 (2's comp) = 11111001
..11110011+
..11111001
111101100
Cutting off lead:
11101100
The first bit is a 1, therefore it is negative.
Using 2's comp to remove negative sign:
00010100
= 20 (decimal)
If the leading digit is a 1, it is negative. You must apply 2's comp (swap then +1) then convert to decimal to get the value of the number (well a positive version of it, just add a negative sign).crammy90 said:i think i get it now..so if it has a leading 1 in 2's comp when we put it back into normal form its negative whatever that number is, if it has a leading 0 in 2's comp when we put it into normal it is positive whatever the number is?