Skip to main content

Floating point division algorithm

Short answer

Sign = sx xor sy. Exponent e = ex - ey + bias. If dividend mantissa ≥ divisor mantissa, shift dividend right and increment e. Divide mantissas, normalize and round. Example: 0.1111×2⁴ ÷ 0.1100×2² = 0.101×2³ = 5.

Draw the flowchart and explain the algorithm for division of floating point numbers.

For floating-point numbers X = mx × 2^ex and Y = my × 2^ey, the quotient is X / Y = (mx / my) × 2^(ex - ey). The mantissas are divided (as in fixed-point division) and the exponents are subtracted.

Algorithm

  1. Check for zeros: if the dividend X is 0, the result is 0. If the divisor Y is 0, signal a divide-by-zero error.
  2. Initialise the registers and find the sign: result sign = sign(X) xor sign(Y).
  3. Subtract the exponents: e = ex - ey, then add the bias back (for biased exponents: e = ex - ey + bias).
  4. Align the dividend: with fractional mantissas (0.1xxx form, as in Mano), if the mantissa of the dividend is greater than or equal to that of the divisor, shift the dividend right and increase the exponent by 1, so that the quotient mantissa is less than 1 and does not overflow.
  5. Divide the mantissas (restoring or non-restoring division) to get the quotient mantissa.
  6. Normalise the quotient and round it. Check for exponent overflow or underflow.
 Start
   |
 X = 0? --yes--> result 0
   | no
 Y = 0? --yes--> divide error
   | no
 sign = sx xor sy
 e = ex - ey + bias
   |
 mx >= my? --yes--> shift mx right, e = e + 1
   | no
 Divide mantissas  (q = mx / my)
   |
 Normalise, round
   |
 Exponent overflow/underflow? --yes--> error
   | no
  Stop

Example

X = 0.1111 × 2⁴ (15), Y = 0.1100 × 2² (3), with fractional mantissas.

  • Exponent: e = 4 - 2 = 2.
  • Align: mx = 0.1111 ≥ my = 0.1100, so shift mx right: 0.01111 × 2⁵, and e = 2 + 1 = 3.
  • Mantissas: 0.01111 ÷ 0.1100 = 0.46875 ÷ 0.75 = 0.625 = 0.101 (already normalised).
  • Result = 0.101 × 2³ = 0.625 × 8 = 5 ✓ (15 ÷ 3 = 5).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Organization and Architecture chapter 5 questions →