Two's compiment numbers HELP!

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
6,966
Reaction score
1,765
Location
At a computer
Can someone please give me the answer to this or at least explain how to calculate the answer.

Ive read the book and its fing useless. Doesnt fing explain a god damn thing and im pi$$ed off now since ive racked my brain on this one equation for over 2 hrs.

Using two compliments arithmetic to calculate: (-52)base10 + (-18)base10 in 8 bits.

Ive managed to get it all down to binaries or so i think it is because when adding the 'negative' you must add a 1 to the least significant bit so tell me if im wrong here:

(-52)base10 = 1100 1111
(-18)base10 = 1110 1111

after that im clueless on how to add the binaries up since they show 1+1 = 0 ( i would think it would be 1 and you carry the other 1 over )
 
52: 0011 0100
complement: 1100 1011
+1: 1100 1100

18: 0001 0010
complement: 1110 1101
+1: 1110 1110

-18 - 52:
1100 1100
1110 1110
=========
1 1011 1010
=========

The 9th bit shows us the sign

Take 1011 1010 - 1:
1011 1001
complement: 0100 0110 = 70

but remember the sign => -70 = -52 - 18
 
Check out http://www.ee.up.ac.za/main/en/undergrad/subjects/ers220/index

Near the end of the page, there is Assignment 1 and its memo. Might be helpful. What book are you using?

Foundations of computer science, Behrouz A.Forouzan.

The problem with the book is it doesn't explain the meaning of some statements: i.e. Compliment each number ( this i understand, change 0's to 1's and 1's to zero's ) but then it says add a 1 to the least significant number ( i finally found out through googling that this is actually always the last number, or furthest right one.
 
52: 0011 0100
complement: 1100 1011
+1: 1100 1100

18: 0001 0010
complement: 1110 1101
+1: 1110 1110

-18 - 52:
1100 1100
1110 1110
=========
1 1011 1010
=========

The 9th bit shows us the sign

Take 1011 1010 - 1:
1011 1001
complement: 0100 0110 = 70

but remember the sign => -70 = -52 - 18

I was looking at your -52 conversion and noticed its different from mine. Realized i posted incorrectly. Its (-56)base10. soz.

Edit: Got the answer in the end finally. 1001010 = 74 ( therefore -74 )

Shot, you really helped me understand more than this useless book ever will.

Can you just explain why 1+1 = 10 ( or zero and carry over the 1 ). that part i dont understand, for now i just do it would like to know why it = 10.
 
Last edited:
No problem. Try get hold of Wakerly's "Digital Design". Helped me a lot. 1decimal plus 1decimal equals 2decimal. this is the same as
1binary plus 1binary equals 10 binary. Remember that the rules work the same, i.e. each space has a weight: starting from the right (Least Significant Bit) and moving left, the weights are 2^0, 2^1, 2^2 etc. In the same way, in decimal it's 10^0, 10^1, 10^2 etc
 
So if you add 6 and 6 in decimal, you get 12, which corresponds to an overflow from the 10^0 digit to the 10^1 digit. Does that help at all?
 
Yeah sort of makes sense.... tutorial is done so i can at least breathe a bit now, and concentrate on figuring this cr@p out
 
Just a side note if they ask you a question like:

"Represent the following numbers in binary (use 8bits) using 2's compliment"

14
-12

Remember that 14 is still: 0000 1110 (or 014 in base 10)
Whereas -12 would then be: 1111 0100 (or 988 in base 10)

In other words, 14 would still be simply converted to binary, because it's not negative.

You can also use a adder for subtraction using this method, by simply dropping the most significant digit. (IE. if you have 14 - 12 = 2 you can use 2's compliment, IE. 014 + 988 = 1002 drop MSD = 2).
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X