Monday, December 21, 2009

How to find the decimal equivalent of the following two's complement numbers?

I do not just want the answer, I would like someone to explain to me how to do it piece by piece. 1011001; 10000011; 111110001How to find the decimal equivalent of the following two's complement numbers?
I'm assuming that is is the two's-complement that is confusing you and not the binary-to-decimal aspect.





Firstly ensure that the number you are converting is negative: if it is the first digit will be 1: a 0 indicates a positive number or zero.





Next, invert all the bits and add one. So, for example 1011001 will invert to 0100110. Add one to get 0100111. Convert this to decimal to get the positive form of the number. Stick a negative sign in front.





Alternatively, do it directly. Calculate the value of all the digits barring the first. The first digit will have the same magnitude as it would normally but opposite sign, so in your first example since it is seven bits the first digit represents -64. Add -64 to the figure you get for all the other digits and you will be left with a negative result (-39 if my mental arithmetic is up to scratch).How to find the decimal equivalent of the following two's complement numbers?
You mean the decimal equivalents?


89


131


497

No comments:

Post a Comment