YAHWT: Binary complements

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Just a quick question.

Determine the decimal values of the following 1's complement numbers:

0111011110

For 1's complement all you do is switch the 1's and 0's. So you get:

1000100001 = (1*2^9) + (1*2^5) + (1*2^0) = 545

But the back of the book gives 478, which I thought was the original decimal value, not the complement. Any thoughts? Am I an idiot? Is the author an idiot?
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Thanks. What about this one?

1011100111

The complement is 0100011000, so the anwer is 280. The back of the book gives -280, is that because the first digit of the original is 1? If it's 0, the number is positive?
 

smack Down

Diamond Member
Sep 10, 2005
4,507
0
0
The book is right.
1st question you don't do anything but convert to decimal.

2ns question when the first digit is a 1 then you take the complement and the result is always negitive.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Originally posted by: smack Down
The book is right.
1st question you don't do anything but convert to decimal.

2ns question when the first digit is a 1 then you take the complement and the result is always negitive.

So if the first digit is 0, you don't need to take the complement, but if the first digit is 1, you do?
 

smack Down

Diamond Member
Sep 10, 2005
4,507
0
0
Originally posted by: nkgreen
Originally posted by: smack Down
The book is right.
1st question you don't do anything but convert to decimal.

2ns question when the first digit is a 1 then you take the complement and the result is always negitive.

So if the first digit is 0, you don't need to take the complement, but if the first digit is 1, you do?

Correct, same applies for 2's complement.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
Originally posted by: Skeeedunt
Aren't you supposed to add a one in there somewhere?

2's complement is a little different. From what my professor explained, start at the right and go until you reach a 1, everything to the left changes and everything to right stays the same.

1011100111 => 0100011001

The last one stays the same because its the first 1 on the left.

Correct?
 

blueshoe

Senior member
Mar 6, 2005
414
0
76
Originally posted by: nkgreen
Originally posted by: Skeeedunt
Aren't you supposed to add a one in there somewhere?

2's complement is a little different. From what my professor explained, start at the right and go until you reach a 1, everything to the left changes and everything to right stays the same.

1011100111 => 0100011001

The last one stays the same because its the first 1 on the left.

Correct?

Yea that's correct. You can also invert the bits and add 1 to get the same thing.
 

eakers

Lifer
Aug 14, 2000
12,169
2
0
Originally posted by: nkgreen
Originally posted by: Skeeedunt
Aren't you supposed to add a one in there somewhere?

2's complement is a little different. From what my professor explained, start at the right and go until you reach a 1, everything to the left changes and everything to right stays the same.

1011100111 => 0100011001

The last one stays the same because its the first 1 on the left.

Correct?

2s compliment = take the 1s compliment and add 1 (or is it the other way around?)

but i like the shortcut way