Originally posted by: Descartes
Most modern number systems use place-value as derived from the Babylonians' first use of it (although the Hindus first made use of zero, I believe), so every digit in a number starting from right to left indicates its placement starting from zero. With that in mind, you can use the following:
n = v * b ^ p
where 'v' is the value (1 or 0 in your case), 'b' is the base (2 in this case), and 'p' is the position of the digit from the right starting at zero. If you do this for each digit you can simply add them all together. Using your example you now have the following:
101011001011 = (1 * 2 ^ 0) + (1 * 2 ^ 1) + (0 * 2 ^ 2) + (1 * 2 ^ 3) ....
Make sense?
Originally posted by: RaynorWolfcastle
Originally posted by: Descartes
Most modern number systems use place-value as derived from the Babylonians' first use of it (although the Hindus first made use of zero, I believe), so every digit in a number starting from right to left indicates its placement starting from zero. With that in mind, you can use the following:
n = v * b ^ p
where 'v' is the value (1 or 0 in your case), 'b' is the base (2 in this case), and 'p' is the position of the digit from the right starting at zero. If you do this for each digit you can simply add them all together. Using your example you now have the following:
101011001011 = (1 * 2 ^ 0) + (1 * 2 ^ 1) + (0 * 2 ^ 2) + (1 * 2 ^ 3) ....
Make sense?
What the hell does that have to do with the price of tea in China?!?
His question was about complementation so that you could use an adder to subtract in a finite length register. JetBlack's answer is correct, assuming the number on the bottom actually is a 1's complement instead of a 2's complement (as it usually is the case
Originally posted by: Descartes
Simma down my fervent brutha.
I saw Legendary's response about the lack of explanation, so I jumped the gun.
Originally posted by: RaynorWolfcastle
Originally posted by: Descartes
Simma down my fervent brutha.
I saw Legendary's response about the lack of explanation, so I jumped the gun.
I'm not angry, I was just completely baffled by your answer to what seemed to be a simple question
:beer:![]()
Originally posted by: JetBlack69
...101011001011 (-1332)
...111111111011 (-4)
--------------------
.1101011000110
..+........................1
..--------------------
...101011000111 (-1336)
The most significant bit is 1 for both numbers, meaning they are negative numbers. Since they are the same sign (negative) you can add them together. Since there is a final carry bit, you need to add 1 to the result to get what is shown above.
EDIT:hmmm...spaces didn't space the problem well. I'll use dots ... just ignore them.
Originally posted by: boomdart
Just to make sure I'm doing this right...
12 bit binary ones complement
101011001011
111111111011
-------------------
101011000110 = 10126 decimal
Correct?
If not please explain.
Originally posted by: JetBlack69
Since it is in one's complement and the most significant bit (on the far left) is 1, I know it is a negative number. Since I want to convert it to decimal, I flip all of the bits (only because I know it's negative) So
101011001011 = -010100110100
Ok, now I can convert it to decimal.
0*2^11 +1*2^10 + 0*2^9 + 1*2^8 + 0*2^7 + 0*2^6 + 1*2^5 + 1*2^4 + 0*2^3 + 1*2^2 + 0*2^1 + 0*2^0
I can ignore anything multiplied with 0 to get:
1*2^10 + 1*2^8 + 1*2^5 + 1*2^4 + 1*2^2
and that equals 1336 and since it's negative a put the negative sign on it -1336
Originally posted by: Descartes
Originally posted by: JetBlack69
Since it is in one's complement and the most significant bit (on the far left) is 1, I know it is a negative number. Since I want to convert it to decimal, I flip all of the bits (only because I know it's negative) So
101011001011 = -010100110100
Ok, now I can convert it to decimal.
0*2^11 +1*2^10 + 0*2^9 + 1*2^8 + 0*2^7 + 0*2^6 + 1*2^5 + 1*2^4 + 0*2^3 + 1*2^2 + 0*2^1 + 0*2^0
I can ignore anything multiplied with 0 to get:
1*2^10 + 1*2^8 + 1*2^5 + 1*2^4 + 1*2^2
and that equals 1336 and since it's negative a put the negative sign on it -1336
What's the going rate for Chinese tea?