Solving Binary Math Problems: Is it Correct?

  • Thread starter Thread starter naspek
  • Start date Start date
  • Tags Tags
    Binary
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
14 replies · 3K views
naspek
Messages
176
Reaction score
0

Homework Statement


http://img593.imageshack.us/img593/3376/76384308.jpg


The Attempt at a Solution


i've got no problem with question a)
but..

i've got couple of question in question b)

my solution is.. 0111 + 1011 = 1 0010
is it correct?

how am i going to verify it in decimal..?
is it -1 + 5 = 4 ?
 
Last edited by a moderator:
Physics news on Phys.org
You're misinterpreting the problem. It's not asking you to find the two's complement of the given numbers; it wants you to interpret them as representing numbers in two's complement form. So 1001 will correspond to some negative number (it's not -1) and 0101 to some positive number. When you add them, you'll get another number that you should again interpret as the two's complement representation of some number. The problem wants you to verify that you indeed get the right answer.
 
vela said:
You're misinterpreting the problem. It's not asking you to find the two's complement of the given numbers; it wants you to interpret them as representing numbers in two's complement form. So 1001 will correspond to some negative number (it's not -1) and 0101 to some positive number. When you add them, you'll get another number that you should again interpret as the two's complement representation of some number. The problem wants you to verify that you indeed get the right answer.

hurmm.. kinda blur.. thanks for ur clarification..
ok.. here what i should do..

add them up.. i got the same answer as part a)...
which is 1110..
should i apply 2's complement on that number (1110)?

if I'm going to verify it using decimal..
i still got the same answer as part a).. right? :confused:
 
naspek said:
hurmm.. kinda blur.. thanks for ur clarification..
ok.. here what i should do..

add them up.. i got the same answer as part a)...
which is 1110..
should i apply 2's complement on that number (1110)?
No, you're supposed to interpret that number as already being in twos' complement form. Since the high bit is 1, it's a negative number. What's the number?
naspek said:
if I'm going to verify it using decimal..
i still got the same answer as part a).. right? :confused:
 
1. What is the two's complement interpretation of 1001?
2. What is the two's complement interpretation of 0101?
3. What is the two's complement interpretation of their sum, 1110?

Note I'm not asking you to find the two's complement of any of these four-bit numbers. I'm asking you what decimal number do they represent when interpreted as a number in two's complement form.

You may find this Wiki article helpful:

http://en.wikipedia.org/wiki/Sign_and_magnitude#Two.27s_complement
 
vela said:
1. What is the two's complement interpretation of 1001?
2. What is the two's complement interpretation of 0101?
3. What is the two's complement interpretation of their sum, 1110?

Note I'm not asking you to find the two's complement of any of these four-bit numbers. I'm asking you what decimal number do they represent when interpreted as a number in two's complement form.

You may find this Wiki article helpful:

http://en.wikipedia.org/wiki/Sign_and_magnitude#Two.27s_complement

1. What is the two's complement interpretation of 1001?
is it 1001 represent -1 in decimal?

2. What is the two's complement interpretation of 0101?
is it 0101 represent +5 in decimal?

3. What is the two's complement interpretation of their sum, 1110?
is it 1110 represent -6?

but.. it seems not correct..
 
Mark44 said:
No, you're supposed to interpret that number as already being in twos' complement form. Since the high bit is 1, it's a negative number. What's the number?

so.. 1110 = -6?
 
Your answer for 1. is incorrect and thus your answer for 3. is also incorrect. Can you show your working for 1. 2. and 3. in converting the binary number to decimal?
 
Zryn said:
Your answer for 1. is incorrect and thus your answer for 3. is also incorrect. Can you show your working for 1. 2. and 3. in converting the binary number to decimal?

2^3 , 2^2, 2^1, 2^0

so.. in 2's complement number..
left most bit 1111 is the sign for the binary number given right?

so.. when 1001 will equal to.. -1 x (2^0) = -1
is it correct?
 
Ahh, now I see.

Indeed the MSB (Most Significant Bit - the left most one) is the sign, however it still retains its value. For example:

1000 0000 = -1 * (2^7) = -128
1001 0001 = -1 * (2^7) + 1 * (2^4) + 1 * (2^0) = -128 + 16 + 1 = -111
1111 1111 = -1 * (2^7) + ... + 1 * (2^0) = -128 + ... + 1 = -1
 
Zryn said:
Ahh, now I see.

Indeed the MSB (Most Significant Bit - the left most one) is the sign, however it still retains its value. For example:

1000 0000 = -1 * (2^7) = -128
1001 0001 = -1 * (2^7) + 1 * (2^4) + 1 * (2^0) = -128 + 16 + 1 = -111
1111 1111 = -1 * (2^7) + ... + 1 * (2^0) = -128 + ... + 1 = -1

fuuhhh~~ now i understand it.. Thanks Zryn!

ok.. so..

1. What is the two's complement interpretation of 1001?
1001 = -9

2. What is the two's complement interpretation of 0101?
0101 still equal to +5 as my answer before..

3. What is the two's complement interpretation of their sum, 1110?
1110 = -14..

but.. how come -9 + 5 = -14?
it should be -4 right?
 
You're closer, but 1. is still wrong, and 3. is wrong for the same reason.

When does -9 + 5 = -14?

And no, it should not be -4 :)

*Hint: Write the equivalent decimal numbers for each bit when you add the signed MSB to the LSB of 1001, what decimal number does each one represent, and what do they sum to? Next, assuming your binary addition is correct and the result is in fact 1110, go through the equivalent decimal number for each bit and then add them together and post what you get (i.e. the format for my previous 3 examples for the 8- bit signed numbers, so each and every calculation is written out in full)
 
Last edited:
Zryn said:
You're closer, but 1. is still wrong, and 3. is wrong for the same reason.

When does -9 + 5 = -14?

And no, it should not be -4 :)

ok2! i got it..!

1001 = [-1 x (2^3)] + [1 x (2^0)]
...= -7
correct?

so..
2nd question still correct..

3rd question...

1110 = [-1 * 2^3] + [1 * 2^2] + [1 * 2^1]
...= -8 + 4 + 2
...= -2
correct ?
 
Yep, spot on!

It was just some wonky addition (-8 + 1 = -9) that was throwing you off.
 
Zryn said:
Yep, spot on!

It was just some wonky addition (-8 + 1 = -9) that was throwing you off.

geez! thank u very much guys! =)