Floating-point arithmetic and loss of precision: Shifting mantissa until exponents match

746 Views Asked by At

My book says the following about floating-point arithmetic involving the addition/subtraction of two numbers, $x$ and $y$, that differ in their exponent:

In adding or subtracting two floating-point numbers, their exponents must match before their mantissas can be added or subtracted. If they do not match initially, then the mantissa of one of the numbers must be shifted until the exponents do match.

The book gives the following example:


enter image description here


I'm having trouble making sense of any of this. I think I do this intuitively without thinking about it, but I'm unable to justify what goes on when we add $1.92403 * 10^2$ to $6.35782 * 10^-1$. What are the intermediate steps that the book is skipping over? Don't we have to factor out (or introduce) powers of 10 to compensate?

1

There are 1 best solutions below

4
On BEST ANSWER

$$\begin{align}x+y&=1.92403\cdot 10^2+6.35782\cdot 10^{-1}\\&=1.92403\cdot 10^2+0.00635782\cdot 10^{2}\\ &\approx 1.92403\cdot 10^2+0.00636\cdot 10^{2}\\ &=(1.92403+0.00636)\cdot 10^2\\ &=1.93039\cdot 10^{2}\end{align} $$