About the calculator
This calculator can be used to multiply 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 multiplication.
important values:
data type | size | exponent | mantisse | bias |
---|---|---|---|---|
binary16 | 16 bits | 5 bits | 10 bits | 15 |
binary32 | 32 bits | 8 bits | 23 bits | 127 |
binary64 | 64 bits | 11 bits | 52 bits | 1023 |
binary128 | 128 bits | 15 bits | 112 bits | 16383 |
Multiplication of binary floating point numbers
2 numbers that are in binary IEEE-754 floating point format can be multiplied using the following steps:
- Convert exponents to decimal numbers
- Prepend implicit 1 to mantissas
- Determine sign
- Add exponents and subtract bias
- Multiply mantissas
- Normalization
- Rounding
- Convert exponent to binary number
- Assemble floating point number
To illustrate the procedure, the following 2 binary floating point numbers should be added together:
and
1. Convert exponents to decimal numbers:
In the first step, the exponents of both numbers are converted into decimal numbers. Alternatively, you can subtract the bias. However, this is not necessary and is not done in the example.
2. Prepend implicit 1 to mantissas:
A "1." is written in front of each mantissa.
In combination with the exponents and the sign bits, the numbers are thus:
3. Determine sign
If the sign bits of the two factors are the same, then the product is positive and the sign bit is therefore 0. Otherwise the product is negative and the sign bit is therefore 1.
The sign bits are different. The sign bit of the solution is therefore 1.
4. Add exponents and subtract bias
Next, the two exponents are added together. If the bias was not subtracted from the exponents in step 1, then the bias must be subtracted from the sum. If the bias was already subtracted in step 1, it is not subtracted from the sum in this step.
133 + 130 − bias | = | 133 + 130 − 127 |
= | 263 − 127 | |
= | 136 |
5. Multiply mantissas
The two mantissas are then multiplied. In principle, multiplying binary numbers works in the same way as multiplying decimal numbers.
Each digit of the second number is multiplied by the first number. The products are either 0 or the first number itself. The products are written one below the other in such a way that as many places are left free behind them as there are places behind the corresponding digit of the second factor. If you start with the last digit of the second factor, then each product is moved one place further to the left than the previous product.
Then for each column the values are added together, from the rightmost column. If the sum of a column is 0 or 1, it is written to the solution. Otherwise, the sum is converted into a binary number, the last digit is written to the solution and the digits before the last digit are converted to a decimal number and written to the row for the carry one column to the left. For example, if the sum of a column is 9, then the binary number is 10012. The last 1 is written to the solution and the 1002 is converted to a decimal number ( this gives 4) and written to the row for the carryovers one column to the left. The binary point of the solution is set so that the solution has as many fractional digits as the two factors together.
Multiply the digits of the second number by the first number:
![Multiply mantissas calculation each digit of the mantissa of the second number is multiplied by the mantissa of the first number](../media/ieee-754/multiply/ieee-754-multiply-calculation.webp)
Add up columns:
![Multiplying the mantissas of the IEEE-754 numbers Multiplying the mantissas of the IEEE-754 numbers](../media/ieee-754/multiply/ieee-754-mult.webp)
The first number has 8 fractional digits and the second has 5, so the solution has 13 fractional digits.
![Multiply IEEE-754 - Set binary point The product of the binary numbers has as many fractional digits as the two binary numbers together.](../media/ieee-754/multiply/ieee-754-multiplication.webp)
6. Normalization
If the binary point is no longer behind the first 1 after multiplication, it must be shifted there. Shifting the binary point also changes the exponent. If the binary point is shifted to the left, the exponent is increased by the number of places that the binary point is shifted and if the binary point is shifted to the right, it is reduced by the number of places that the binary point is shifted to the right.
The binary point must be shifted one place to the left. The exponent must therefore be increased by 1.
−1.101011100010112 ∙ 2137 − bias
7. Rounding
If the number has more fractional digits than the binary floating point number can store, it must be rounded. In most cases, it is rounded to the nearest representable number. The bit after the least significant bit (the last bit that can be stored in the mantissa of the floating point number) is looked at for this purpose. If there is a 1 directly after the least significant bit and it is not followed by a 1 in at least one other place, then the number lies exactly in the middle between 2 representable numbers. In this case, the number is rounded so that the least significant bit is 0. If there is a 1 in the bit after the least significant bit and this is followed by a 1 in at least one further place, then the number with the greater absolute value is the nearest representable number. If the least significant bit is followed by a 0, then the number with the smaller absolute value is the nearest number that can be represented.
In the example, the number has 14 fractional digits. 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 converted into a binary number. If the bias was subtracted in step 1, it must be added beforehand.
137 is converted into a binary number: 100010012
9. Assemble floating point number
Finally, all components are combined to form a binary floating point number in the IEEE-754 standard.
The sign bit was determined in step 3.
The exponent bits calculated in step 8 are written to the exponent part. If the exponent bits are not sufficient to completely fill the exponent part, the exponent part is filled with zeros at the front.
The fractional digits of the normalized and rounded number are written to the mantissa part of the floating point number. If there are still free bits in the mantissa part, it is filled with zeros at the end.