# Floating Point/Floating Point Arithmetic

## ArithmeticEdit

Floating point numbers would be useless if we couldnt operate on them. Fortunately, there are algorithms for performing the basic arithmetic operations (Addition, subtraction, multiplication, division), as well as other operations such as exponentials, square-roots, and trancendentals. This page will introduce some of the basic arithmetic operations, and more advanced algorithms will be saved for a later page.

## MultiplicationEdit

Let's multiply the following two numbers:

Variable sign exponent fraction X 0 1001 010 Y 0 0111 110

Here are the steps again:

- First, convert the two representations to scientific notation. Thus, we explicitly represent the hidden 1.
- In this case, X is 1.01 X 22 and Y is 1.11 X 20.
- Let x be the exponent of X. Let y be the exponent of Y. The resulting exponent (call it z) is the sum of the two exponents. z may need to be adjusted after the next step.
- For now, the resulting exponent is 2 + 0 = 2
- Multiply the mantissa of X to the mantissa of Y. Call this result m.
- Multiplying 1.01 by 1.11 results in 10.0011
- If m is does not have a single 1 left of the radix point, then adjust the radix point so it does, and adjust the exponent z to compensate.
- Now, we have to renormalize 10.0011 to 1.00011 and increase the exponent by 1 to 3
- Add the sign bits, mod 2, to get the sign of the resulting multiplication.
- The sign bit is 0 + 0 = 0.
- Convert back to the one byte floating point representation, truncating bits if needed.
- We need to truncate 1.00011 x 23 to 1.000 x 23 and convert.

Product sign exponent fraction X * Y 0 1010 000