110110 ÷ 101 — binary arithmetic

corelong division with a remainder

Answer

001010 remainder 000100

Why this example is worth doing

Binary long division, where each step asks only whether the divisor fits — the quotient digit is 1 or 0 and never anything else. That makes the mechanics simpler than decimal division even though the working is longer. Fifty-four divided by five is ten remainder four, and the page prints the restoring-division trace that a hardware divider actually follows.

Try your own input in the Binary arithmetic. Add, subtract, multiply and divide in binary with every carry and borrow shown.

How the answer is reached

110110 / 000101 (6-bit unsigned)

110110 / 000101 (6-bit unsigned) — columns operand, bits, hex, unsigned, signed
operandbitshexunsignedsigned
A1101100x3654-10
B0001010x0555

Restoring division: shift the remainder left, bring down the next bit, subtract the divisor. If the result is negative, restore it and emit quotient bit 0; otherwise keep it and emit 1.

110110 / 000101 (6-bit unsigned) — columns step, remainder after shift, trial subtract, restore?, quotient bit
stepremainder after shifttrial subtractrestore?quotient bit
100000010000001 - 0000101 = -4yes0
200000110000011 - 0000101 = -2yes0
300001100000110 - 0000101 = 1no1
400000110000011 - 0000101 = -2yes0
500001110000111 - 0000101 = 2no1
600001000000100 - 0000101 = -1yes0

quotient001010 = 10

remainder000100 = 4

check10 x 5 + 4 = 54

Compare with

Open the Binary arithmetic

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Fractions are converted digit by digit and shown to a stated number of places rather than rounded silently.

Sources

  • Knuth, The Art of Computer Programming, Vol. 2, §4.3.1 “The Classical Algorithms” (1997)