Binary multiplication for negative numbers
$begingroup$
The question is about binary multiplication for negative numbers. Assume we want to multiply -5 * -3 so the result is +15.
1) In the first step, we have to use 2's complement for the inputs.
+5 = 0101 -> -5 = 1011
+3 = 0011 -> -3 = 1101
2) We follow the simple pencil-and-paper method and we have to note the sign extension. For the sake of clarity I put the signs extensions in
1011
* 1101
----------------
[1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1] 1 0 1 1
1 0 1 1 +
------------------------------
c7 c6 c5 c4 c3 c2 c1
3) summing the columns show that
c1 = 1 + 0 + 0 + 0 = 1
c2 = 1 + 0 + 0 + 0 = 1
c3 = 0 + 0 + 1 + 0 = 1
c4 = 1 + 0 + 1 + 1 = 1 (carry 1 to c5)
c5 = 1(carry) + 1(sign) + 0 + 0 + 1 = 1 (carry 1 to c6)
c6 = 1(carry) + 1(sign) + 0(sign) + 1 + 0 = 1 (carry 1 to c7)
c7 = 1(carry) + 1(sign) + 0(sign) + 1(sign) + 1 = ???
Actually c7 = 100 but we have to represent only one digit in c7. So does that mean
c7 = 0 (carry 10)
?? Usually the final carry bit is only one digit. More than that, the final number is not equal to +15. Where did I make the mistake?
arithmetic binary-operations
$endgroup$
add a comment |
$begingroup$
The question is about binary multiplication for negative numbers. Assume we want to multiply -5 * -3 so the result is +15.
1) In the first step, we have to use 2's complement for the inputs.
+5 = 0101 -> -5 = 1011
+3 = 0011 -> -3 = 1101
2) We follow the simple pencil-and-paper method and we have to note the sign extension. For the sake of clarity I put the signs extensions in
1011
* 1101
----------------
[1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1] 1 0 1 1
1 0 1 1 +
------------------------------
c7 c6 c5 c4 c3 c2 c1
3) summing the columns show that
c1 = 1 + 0 + 0 + 0 = 1
c2 = 1 + 0 + 0 + 0 = 1
c3 = 0 + 0 + 1 + 0 = 1
c4 = 1 + 0 + 1 + 1 = 1 (carry 1 to c5)
c5 = 1(carry) + 1(sign) + 0 + 0 + 1 = 1 (carry 1 to c6)
c6 = 1(carry) + 1(sign) + 0(sign) + 1 + 0 = 1 (carry 1 to c7)
c7 = 1(carry) + 1(sign) + 0(sign) + 1(sign) + 1 = ???
Actually c7 = 100 but we have to represent only one digit in c7. So does that mean
c7 = 0 (carry 10)
?? Usually the final carry bit is only one digit. More than that, the final number is not equal to +15. Where did I make the mistake?
arithmetic binary-operations
$endgroup$
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28
add a comment |
$begingroup$
The question is about binary multiplication for negative numbers. Assume we want to multiply -5 * -3 so the result is +15.
1) In the first step, we have to use 2's complement for the inputs.
+5 = 0101 -> -5 = 1011
+3 = 0011 -> -3 = 1101
2) We follow the simple pencil-and-paper method and we have to note the sign extension. For the sake of clarity I put the signs extensions in
1011
* 1101
----------------
[1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1] 1 0 1 1
1 0 1 1 +
------------------------------
c7 c6 c5 c4 c3 c2 c1
3) summing the columns show that
c1 = 1 + 0 + 0 + 0 = 1
c2 = 1 + 0 + 0 + 0 = 1
c3 = 0 + 0 + 1 + 0 = 1
c4 = 1 + 0 + 1 + 1 = 1 (carry 1 to c5)
c5 = 1(carry) + 1(sign) + 0 + 0 + 1 = 1 (carry 1 to c6)
c6 = 1(carry) + 1(sign) + 0(sign) + 1 + 0 = 1 (carry 1 to c7)
c7 = 1(carry) + 1(sign) + 0(sign) + 1(sign) + 1 = ???
Actually c7 = 100 but we have to represent only one digit in c7. So does that mean
c7 = 0 (carry 10)
?? Usually the final carry bit is only one digit. More than that, the final number is not equal to +15. Where did I make the mistake?
arithmetic binary-operations
$endgroup$
The question is about binary multiplication for negative numbers. Assume we want to multiply -5 * -3 so the result is +15.
1) In the first step, we have to use 2's complement for the inputs.
+5 = 0101 -> -5 = 1011
+3 = 0011 -> -3 = 1101
2) We follow the simple pencil-and-paper method and we have to note the sign extension. For the sake of clarity I put the signs extensions in
1011
* 1101
----------------
[1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1] 1 0 1 1
1 0 1 1 +
------------------------------
c7 c6 c5 c4 c3 c2 c1
3) summing the columns show that
c1 = 1 + 0 + 0 + 0 = 1
c2 = 1 + 0 + 0 + 0 = 1
c3 = 0 + 0 + 1 + 0 = 1
c4 = 1 + 0 + 1 + 1 = 1 (carry 1 to c5)
c5 = 1(carry) + 1(sign) + 0 + 0 + 1 = 1 (carry 1 to c6)
c6 = 1(carry) + 1(sign) + 0(sign) + 1 + 0 = 1 (carry 1 to c7)
c7 = 1(carry) + 1(sign) + 0(sign) + 1(sign) + 1 = ???
Actually c7 = 100 but we have to represent only one digit in c7. So does that mean
c7 = 0 (carry 10)
?? Usually the final carry bit is only one digit. More than that, the final number is not equal to +15. Where did I make the mistake?
arithmetic binary-operations
arithmetic binary-operations
asked Oct 4 '15 at 10:27
mahmoodmahmood
13228
13228
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28
add a comment |
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
1011
* 1101
----------------
[1][1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1][1] 1 0 1 1
[1] 1 0 1 1 +
1 0 1 1
... 1 1
------------------------------
c7 c6 c5 c4 c3 c2 c1
Does this clarify it?
If you keep going to the left, you will wind up carrying infinitely many bits. But that's as it should be. The actual answer on the right winds up as ...01111 when you include the 1011 entry ending in column 5. The more 1011 entries you include (ending at c6, c7, etc.) the more zeros you'll have at the start of your answer.
I don't know any textbook answer for where to stop going to the left, but you can at least see it conceptually from the above.
$endgroup$
add a comment |
$begingroup$
I believe the answer given by "Wildcard" does not fully answer this question. He does not extend the sign before multiplication, which could cause confusion in new viewers. Furthermore, you don't "multiply forever to wind up with infinite bits", the signs are simply extended beforehand. So this should look better:
1 1 1 1 1 0 1 1 = -5
* 1 1 1 1 1 1 0 1 = -3
--------------------------------------------
1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
--------------------------------------------
discarded| 0 0 0 0 1 1 1 1 = +15
The bits at the end are discarded because the number is 8 bit.
Reference and Further Reading: https://en.wikipedia.org/wiki/Two%27s_complement
$endgroup$
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
add a comment |
$begingroup$
When you multiply two negative numbers,in the last term you have to write 2's complement of the first number.In this case 2's complement of 1011 is 0101. I put 2's complement in ().
1011
* 1101
----------------------------------
[1] [1] [1] [1] 1 0 1 1
[0] [0] [0] 0 0 0 0 x
[1] [1] 1 0 1 1 x x
[0] (0 1 0 1) x x x +
----------------------------------
0 0 0 0 1 1 1 1
Discard the remaining bit as we need answer in 8-bit if we keep moving to the left we only get more 0 on the left of number.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1463651%2fbinary-multiplication-for-negative-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
1011
* 1101
----------------
[1][1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1][1] 1 0 1 1
[1] 1 0 1 1 +
1 0 1 1
... 1 1
------------------------------
c7 c6 c5 c4 c3 c2 c1
Does this clarify it?
If you keep going to the left, you will wind up carrying infinitely many bits. But that's as it should be. The actual answer on the right winds up as ...01111 when you include the 1011 entry ending in column 5. The more 1011 entries you include (ending at c6, c7, etc.) the more zeros you'll have at the start of your answer.
I don't know any textbook answer for where to stop going to the left, but you can at least see it conceptually from the above.
$endgroup$
add a comment |
$begingroup$
1011
* 1101
----------------
[1][1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1][1] 1 0 1 1
[1] 1 0 1 1 +
1 0 1 1
... 1 1
------------------------------
c7 c6 c5 c4 c3 c2 c1
Does this clarify it?
If you keep going to the left, you will wind up carrying infinitely many bits. But that's as it should be. The actual answer on the right winds up as ...01111 when you include the 1011 entry ending in column 5. The more 1011 entries you include (ending at c6, c7, etc.) the more zeros you'll have at the start of your answer.
I don't know any textbook answer for where to stop going to the left, but you can at least see it conceptually from the above.
$endgroup$
add a comment |
$begingroup$
1011
* 1101
----------------
[1][1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1][1] 1 0 1 1
[1] 1 0 1 1 +
1 0 1 1
... 1 1
------------------------------
c7 c6 c5 c4 c3 c2 c1
Does this clarify it?
If you keep going to the left, you will wind up carrying infinitely many bits. But that's as it should be. The actual answer on the right winds up as ...01111 when you include the 1011 entry ending in column 5. The more 1011 entries you include (ending at c6, c7, etc.) the more zeros you'll have at the start of your answer.
I don't know any textbook answer for where to stop going to the left, but you can at least see it conceptually from the above.
$endgroup$
1011
* 1101
----------------
[1][1] [1] [1] 1 0 1 1
[0] [0] 0 0 0 0
[1][1] 1 0 1 1
[1] 1 0 1 1 +
1 0 1 1
... 1 1
------------------------------
c7 c6 c5 c4 c3 c2 c1
Does this clarify it?
If you keep going to the left, you will wind up carrying infinitely many bits. But that's as it should be. The actual answer on the right winds up as ...01111 when you include the 1011 entry ending in column 5. The more 1011 entries you include (ending at c6, c7, etc.) the more zeros you'll have at the start of your answer.
I don't know any textbook answer for where to stop going to the left, but you can at least see it conceptually from the above.
answered Oct 4 '15 at 11:08
WildcardWildcard
2,6451028
2,6451028
add a comment |
add a comment |
$begingroup$
I believe the answer given by "Wildcard" does not fully answer this question. He does not extend the sign before multiplication, which could cause confusion in new viewers. Furthermore, you don't "multiply forever to wind up with infinite bits", the signs are simply extended beforehand. So this should look better:
1 1 1 1 1 0 1 1 = -5
* 1 1 1 1 1 1 0 1 = -3
--------------------------------------------
1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
--------------------------------------------
discarded| 0 0 0 0 1 1 1 1 = +15
The bits at the end are discarded because the number is 8 bit.
Reference and Further Reading: https://en.wikipedia.org/wiki/Two%27s_complement
$endgroup$
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
add a comment |
$begingroup$
I believe the answer given by "Wildcard" does not fully answer this question. He does not extend the sign before multiplication, which could cause confusion in new viewers. Furthermore, you don't "multiply forever to wind up with infinite bits", the signs are simply extended beforehand. So this should look better:
1 1 1 1 1 0 1 1 = -5
* 1 1 1 1 1 1 0 1 = -3
--------------------------------------------
1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
--------------------------------------------
discarded| 0 0 0 0 1 1 1 1 = +15
The bits at the end are discarded because the number is 8 bit.
Reference and Further Reading: https://en.wikipedia.org/wiki/Two%27s_complement
$endgroup$
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
add a comment |
$begingroup$
I believe the answer given by "Wildcard" does not fully answer this question. He does not extend the sign before multiplication, which could cause confusion in new viewers. Furthermore, you don't "multiply forever to wind up with infinite bits", the signs are simply extended beforehand. So this should look better:
1 1 1 1 1 0 1 1 = -5
* 1 1 1 1 1 1 0 1 = -3
--------------------------------------------
1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
--------------------------------------------
discarded| 0 0 0 0 1 1 1 1 = +15
The bits at the end are discarded because the number is 8 bit.
Reference and Further Reading: https://en.wikipedia.org/wiki/Two%27s_complement
$endgroup$
I believe the answer given by "Wildcard" does not fully answer this question. He does not extend the sign before multiplication, which could cause confusion in new viewers. Furthermore, you don't "multiply forever to wind up with infinite bits", the signs are simply extended beforehand. So this should look better:
1 1 1 1 1 0 1 1 = -5
* 1 1 1 1 1 1 0 1 = -3
--------------------------------------------
1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 0 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
1 1 1 1 1 0 1 1 | |
--------------------------------------------
discarded| 0 0 0 0 1 1 1 1 = +15
The bits at the end are discarded because the number is 8 bit.
Reference and Further Reading: https://en.wikipedia.org/wiki/Two%27s_complement
edited Feb 7 '18 at 10:24
answered Feb 6 '18 at 14:35
Eduard GeorgievEduard Georgiev
113
113
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
add a comment |
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
$begingroup$
Welcome to Math.SE. Beware of posting answers that are substantially shorter than the corresponding Question. In this case you are tackling a 2+ year old Question which already had an upvoted Answer, so it would have made sense to highlight what information you are adding to the solution.
$endgroup$
– hardmath
Feb 6 '18 at 16:36
1
1
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
$begingroup$
I edited my answer. I was wrong, multiplication can be done, I don't know why wikipedia said it couldn't. I will do further reading later today and maybe revisit my answer. Still, I believe that currently my answer adds more to the topic. If you can remove your downvote it would mean the world to me.
$endgroup$
– Eduard Georgiev
Feb 7 '18 at 10:25
add a comment |
$begingroup$
When you multiply two negative numbers,in the last term you have to write 2's complement of the first number.In this case 2's complement of 1011 is 0101. I put 2's complement in ().
1011
* 1101
----------------------------------
[1] [1] [1] [1] 1 0 1 1
[0] [0] [0] 0 0 0 0 x
[1] [1] 1 0 1 1 x x
[0] (0 1 0 1) x x x +
----------------------------------
0 0 0 0 1 1 1 1
Discard the remaining bit as we need answer in 8-bit if we keep moving to the left we only get more 0 on the left of number.
$endgroup$
add a comment |
$begingroup$
When you multiply two negative numbers,in the last term you have to write 2's complement of the first number.In this case 2's complement of 1011 is 0101. I put 2's complement in ().
1011
* 1101
----------------------------------
[1] [1] [1] [1] 1 0 1 1
[0] [0] [0] 0 0 0 0 x
[1] [1] 1 0 1 1 x x
[0] (0 1 0 1) x x x +
----------------------------------
0 0 0 0 1 1 1 1
Discard the remaining bit as we need answer in 8-bit if we keep moving to the left we only get more 0 on the left of number.
$endgroup$
add a comment |
$begingroup$
When you multiply two negative numbers,in the last term you have to write 2's complement of the first number.In this case 2's complement of 1011 is 0101. I put 2's complement in ().
1011
* 1101
----------------------------------
[1] [1] [1] [1] 1 0 1 1
[0] [0] [0] 0 0 0 0 x
[1] [1] 1 0 1 1 x x
[0] (0 1 0 1) x x x +
----------------------------------
0 0 0 0 1 1 1 1
Discard the remaining bit as we need answer in 8-bit if we keep moving to the left we only get more 0 on the left of number.
$endgroup$
When you multiply two negative numbers,in the last term you have to write 2's complement of the first number.In this case 2's complement of 1011 is 0101. I put 2's complement in ().
1011
* 1101
----------------------------------
[1] [1] [1] [1] 1 0 1 1
[0] [0] [0] 0 0 0 0 x
[1] [1] 1 0 1 1 x x
[0] (0 1 0 1) x x x +
----------------------------------
0 0 0 0 1 1 1 1
Discard the remaining bit as we need answer in 8-bit if we keep moving to the left we only get more 0 on the left of number.
edited Dec 26 '18 at 6:15
answered Dec 26 '18 at 6:06
Hamza BhattiHamza Bhatti
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1463651%2fbinary-multiplication-for-negative-numbers%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Shouldn't you be using signs extensions for BOTH numbers? That would put another 1011 ending in c5, another ending in c6, another ending in c7...just keep going until the pattern winds up all zeros with the same carry each time.
$endgroup$
– Wildcard
Oct 4 '15 at 10:59
$begingroup$
gosh, you managed to pack so many mistakes into one set of solution...
$endgroup$
– Matian2040
Feb 7 at 7:28