If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Multiplying in binary

To multiply numbers in base 2, we can use the same process as we would in base 10, but with only two digits: 0 and 1. Start by multiplying the rightmost digit of one number by each digit of the other number, working left. Keep track of any "carries" (when the product is 2, carry over a 1 to the next column). Finally, add up all the partial products.

Want to join the conversation?

  • hopper cool style avatar for user Madeliv
    How would you go about multiplying hexadecimal numbers (for example: AF3 * FF) ?
    (11 votes)
    Default Khan Academy avatar avatar for user
    • leafers tree style avatar for user Mr. Taylor-Pestell
      I believe your question was how to perform multiplication using the hexadecimal numbers (not converting them into decimal or binary first). If this is correct, then the following work shows the steps. Unfortunately, this may be very difficult to follow because of my methods of calculating and the fact that I cannot write out my steps in the way Sal Khan does (so I apologize in advance):
      (Reminder: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F)
      AF3 * FF
      AF3 * F => A00 * F + F0 * F + 3 * F =>
      // Note: This expansion comes from the distributive property and understanding
      place value (e.g., by seeing the A in the far left as the value A00)
      3 * F = 2D
      F * F (or (10 - 1) * (10 - 1) = 101 - 20 = E1
      // Note: 10 represent 1 sixteen and 0 ones, which is why 10 - 2 = E (not 8)
      So ... F0 * F + 2D = E3D
      A * F (or (10 - 6) * (10 - 1) = 106 - 70 = 96
      So ... A00 * F + E3D = A43D
      AF3 * FF = AF3 * F + AF3 * F0 = A43D + A43D0 = AE80D
      AF3 (dec --> 2560 + 240 + 3 = 2803) times FF (dec --> 255) = AE80D (dec --> 655360 + 57344 + 2048 + 0 + 13 = 714765)
      || Q.E.D. ||
      (15 votes)
  • spunky sam red style avatar for user Marvin Cohen
    Can you also divide in binary terms?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • leafers tree style avatar for user Mr. Taylor-Pestell
      Here is an example of using the long division algorithm with binary numbers. As Poveda7938 stated, it is easy (due to the simplicity of numbers in each place, that is, 0 or 1).
      I apologize for the formatting issues; it's not accepting my text as typed, so I am writing the steps you would take to show long division.
      216/8 --> 8 | 2 1 6 // Note that 216 = 128 + 64 + 16 + 8 or (11011000 in binary)

      Quotient is 00 011 011 ( 10 000 + 1 000 + 000 + 10 + 1)
      1 000 | 11 011 000
      10 000 * 1 000 = 10 000 000
      11 011 000 = 10 000 000 = 1 011 000
      1 000 * 1 000 = 1 000 000
      1 011 000 - 1 000 000 = 11 000
      10 * 1 000 = 10 000
      11 000 - 10 000 = 1 000
      1 * 1 000 = 1 000
      1 000 - 1 000 = 0

      11 011 * 1 000 = 11 011 000
      27 * 8 = 216
      (5 votes)
  • starky sapling style avatar for user XxTheBanexX
    is binary useful or a just skill to learn for the fun of it?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • aqualine seedling style avatar for user lawlaw
    How would you carry two ones?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Nicolas Posunko
      Same logic, even if when you carry two ones from addition in the previous place, you also get two more ones from addition in the next place, you keep in mind that:

      1 (decimal) = 1 (binary)
      2 (decimal) = 10 (binary)
      3 (decimal) = 11 (binary)
      4 (decimal) = 100 (binary)

      And you're ready to go; just carry a one one place further to the left, and that's it.

      Hope this helps!
      (5 votes)
  • duskpin ultimate style avatar for user Pranav Chandra
    How do you divide binary numbers?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user mohamed doudou
    Thanks for the Video, but what if we have a number negative multiplying in positive number how should we do that ? i didn't find videos in this case
    (3 votes)
    Default Khan Academy avatar avatar for user
  • old spice man green style avatar for user Surjo
    Can you do negative binary numbers like our normal base-10 negative numbers.
    For example, in base 10, you just put a negative sign in the back of the number and it turns negative like 2 ----> -2. Would it be the same for binary? 11 is binary for 3, so would -11 mean binary for -3?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • piceratops sapling style avatar for user Ali Decalt
    Is dividing in binary the same as it is in decimal?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • duskpin ultimate style avatar for user Sa  Kuks
    I don't understand why :
    -9 is represented as 1001
    -7 is represented as 101
    WHY IS IT SO?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • spunky sam blue style avatar for user SHODE
      1001
      8421
      8001 <--> 1001
      add 8 and 1=9

      101
      421
      401 <--> 101 ((btw 101 is represented as 5 not 7 ))
      add 4 and 1 = 5
      i have a hard time explaining it just try analyzing that :v
      oh and its been a year since u asked this but still hope it helps some who also had a hard time understanding that part -w-
      (0 votes)
  • blobby green style avatar for user mi1674328
    How would you go about multiplying hexadecimal numbers (for example: AF3 * FF) ?
    (1 vote)
    Default Khan Academy avatar avatar for user

Video transcript

- I now want to show you that the standard algorithm for multiplying numbers can also be used, it's not just limited to base 10, it can also be used, frankly it can be used in any base, but we're going to do it in base two. And base two is especially fun, because you essentially have only to know your multiplication tables through one. So you just have to know that zero times zero is zero, one times zero is zero, and that one times one is one. And then you're ready to go, you're ready to multiply in base two. So let's do that. So let's say we have... Let's say we take nine, so let's see, nine is going to be one eight zero fours, zero twos and one. So this is nine, right over here, represented in base two. And let's say we were to multiply that times seven, so we should, obviously, if we know our multiplication tables we should get 63. So seven is one; actually I'm going to put a zero, seven would be one one one, but that's a little bit boring so let's instead do nine times five, which we know should be 45. So this is one four, no twos, and one one. So four plus one is going to be five. So this is nine times five and we're doing it in base two. So once again, same algorithm. And actually, before I do it, I encourage you to just pause the video, and try to use the same algorithm that you've used for base ten multiplication, use the same algorithm here and let's see if we actually do get that nine times five is 45. So I'm assuming you've had a go at it, let's work through it together. So let's start right over here in the ones place. So we multiply, one times one is one, one times zero is zero, one times zero is zero, one times one is one. Then, we can go to the twos place and since we're multiplying all of this times the twos place, we can throw a zero right over here. But, of course, zero times each of these is just going to be a bunch of zeros, you know, zero times one is zero, zero times zero is zero, zero times zero is zero, zero times one is zero. So I really didn't have to write that, but I'm just doing it so that you see that I'm using the standard algorithm. And then, we go to the fours place. And since we're in the fours place, let's put some zeros here. So zero, zero. We're essentially talking about a certain number of fours, not a certain number of ones. So one times that is just going to be one, zero, zero, one. And now we're ready to add. Now we are ready to add. So one plus a bunch of zeros is one, a bunch of zeros, that's going to be one, one plus a bunch of zeros is one, zeros, and one. And we're done. And obviously if we had more than one one in any of these places right over here, then we might have had to carry a one. But we saw that, when we added numbers in binary. Well, let's actually verify that this is the number that we would expect it to be. Remember, this right over here is the ones place- so let's see, this is ones, fours, let me write it down, this is ones, twos, fours, eights, 16s and 32s. So we have one 32, so it's going to be 32, plus one eight, and once again, we only have to do this for ourselves because we're so used to thinking in base 10. If we were thinking in base two, you'd say, "Oh, I know what this number is," and you would have some name for it, probably different than 45, because 45, the name essentially is kind of a base 10 name and we'd probably have better names in terms of base two. Somebody should actually do that, that would be a fun project. So let's see, we have 32, plus eight, plus four, plus four, plus one, plus one. Which is indeed equal to 45.