Dividing floating point numbers (IEEE-754)

required files are loaded...
settings:
URL copied

About the calculator

This calculator can be used to divide 2 binary IEEE-754 floating point numbers. You can select whether the input numbers are binary floating point numbers in binary or hexadecimal representation or whether they are decimal numbers. If they are decimal numbers, they are converted into binary floating point numbers before division.

important values:

data typesizeexponentmantissebias
binary1616 bits5 bits10 bits15
binary3232 bits8 bits23 bits127
binary6464 bits11 bits52 bits1023
binary128128 bits15 bits112 bits16383

Dividing binary floating point numbers

2 Numbers that are in binary IEEE-754 floating point format can be divided using the following steps:

  1. Convert exponents to decimal numbers
  2. Prepend implicit 1 to mantissas
  3. Determine sign
  4. Subtract exponents and add bias
  5. Divide mantissas
  6. Normalization
  7. Rounding
  8. Convert exponent to binary number
  9. Assemble floating point number

To illustrate the procedure,

11000011000000111000100000000000

should be divided by

11000001011101000000000000000000

.

1. Convert exponents to decimal numbers:

First, the exponents of the two binary floating point numbers are converted into decimal numbers. The bias can be subtracted, but this is not necessary and is not done in the example.

number 1:
100001102 = 128 + 4 + 2 = 134

number 2:
100000102 = 128 + 2 = 130

2. Prepend implicit 1 to mantissas

A "1." is then written in front of the two mantissas.

number 1:
1.00000111000100000000000

number 2:
1.11101000000000000000000

In combination with the exponents and the sign bits, the numbers are thus:

number 1:
-1.0000011100012 ∙ 2134 − bias

number 2:
-1.111012 ∙ 2130 − bias

3. Determine sign

If both floating point numbers have the same sign, then the quotient is positive and the sign bit is 0. If the sign bits of the two floating point numbers differ, then the quotient is negative and the sign bit is 1.

The sign bits are the same. The sign bit of the solution is therefore 0.

4. Subtract exponents and add bias

The exponent of the divisor is subtracted from the exponent of the dividend. If the bias was not subtracted from the two exponents in step 1, the bias must be added to the difference.

134 − 130 + bias = 134 − 130 + 127
 = 4 + 127
 = 131

5. Divide mantissas

Next, the mantissa of the dividend is divided by the mantissa of the divisor. In principle, dividing binary numbers works in the same way as dividing decimal numbers.

The binary points of the dividend and of the divisor are shifted to the right by the same number of digits until the divisor no longer has any fractional digits.

The dividend is then passed through digit by digit, starting from the left. The current digit is brought down in each step. This means that in the first step the first digit is written under the first digit and then in each step the current digit is appended to the number that is currently the bottommost number in the calculation. If the bottommost number is then smaller than the divisor, a 0 is appended to the solution. If the current lowest number of the calculation is not less than the divisor, then a 1 is appended to the solution and the divisor is subtracted from the current bottommost number of the calculation. If a binary point is reached in the dividend or if all digits of the dividend have just been brought down once and the solution does not yet contain a binary point, then a binary point is added to the solution. If all digits of the dividend have been "used up", the bottommost number of the calculation is not yet 0 and the calculation is to be continued, then a 0 is appended to the bottommost number in each of the following steps. The calculation continues until all digits of the dividend have been brought down once and until either the bottommost digit is 0 or until there are as many digits after the first 1 of the solution as fit into the mantissa plus an additional digit for rounding.

The mantissa of the divisor has 5 fractional digits after placing the "1." in front and after deleting the trailing zeros. The binary point must therefore be shifted 5 places to the right from both mantissas.

Dividing binary numbers - task

For the first 6 steps of the division, the current bottommost number is smaller than the divisor. In each of these steps, a 0 is written in the solution row.

Dividing binary numbers - 1

As the binary point has now been reached, a binary point is appended to the solution.

Dividing binary numbers - 2

After the 1 has been brought down, the bottommost number is greater than the divisor this time and therefore a 1 is appended to the solution and the divisor is subtracted from the bottommost number.

Dividing binary numbers - 3

The next three steps, the bottom number is smaller than the divisor and therefore 3 zeros are appended to the solution.

Dividing binary numbers - 5

After bringing down the next 0, the bottom number is greater than the divisor and therefore a 1 is appended to the solution and the divisor is subtracted from the bottommost number.

Dividing binary numbers - 6

In the next step, the bottommost number is again smaller than the divisor.

Dividing binary numbers - 7

And then the bottommost number is equal to the divisor and therefore a 1 is appended and the divisor is subtracted.

Dividing binary numbers

Since all the digits of the dividend have been used up and the number at the very bottom is 0, the exact solution has now been found.

The quotient is therefore:
0.10001012 ∙ 2131 − bias

6. Normalization

If the binary point of the quotient is not directly behind the first 1, then it must be shifted. If the decimal point has to be shifted, the exponent is also adjusted accordingly. If the binary point has to be shifted one place to the right, the exponent is reduced by 1.

The binary point must be shifted one place to the right. The exponent must therefore be reduced by 1.

1.0001012 ∙ 2130 − bias

7. Rounding

If the quotient has more fractional digits than the number of digits that fit into the mantissa of the binary floating point number, the quotient must be rounded. Normally it is rounded to the nearest representable number. To do this, the digit after the least significant bit is considered. The least significant bit is the last bit that still fits in the mantissa. If the digit after the least significant bit is a 1 and no further 1 follows (and the calculation was not canceled), then the quotient lies exactly in the middle between 2 representable numbers. In this case, rounding is performed so that the least significant bit is 0 after rounding. If the digit after the least significant bit is 0, then the next representable number is the smaller number according to amount. If the digit after the least significant bit is a 1 and if there is a 1 in at least one further digit (or if the calculation has been canceled), then the nearest representable number is the larger representable number according to amount.

In the example, the number has 6 decimal places. The mantissa of a binary floating point number with 32 bits has space for 23 bits. Therefore, the number does not need to be rounded.

8. Convert exponent to binary number

The exponent is then converted into a binary number. If the bias was subtracted in step 1, it must be added in this step before the conversion to a binary number.

130 is converted into a binary number: 100000102

9. Assemble floating point number

The last step is to assemble the 3 components into a binary floating point number.

The sign bit was determined in step 3.

The exponent bits calculated in step 8 are written to the exponent part. If these do not completely fill the exponent part, it is filled with zeros at the front.

The fractional digits of the normalized and rounded mantissa belong in the mantissa part. If these do not completely fill the mantissa part, it is filled with zeros at the end.

The solution is:
01000001000010100000000000000000

good explanatory videos on Youtube

Share:FacebookTwitter