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 Answer 1


$$\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} $$

  • $\begingroup$ Oh, it's like multiplying and dividing $y$ by $10^3$, but distributing those to the mantissa and $10^{exp}$, such that the mantissa becomes smaller while the exponent becomes larger. The result remains the "same" from our perspective, but in terms of precision, we have effectively lost the "8" and the "2" from $y$ because it is assumed that our computations are only as accurate as the lowest precision of the inputs (6 significant digits). Did I understand this correctly? $\endgroup$ Sep 5, 2019 at 20:06
  • $\begingroup$ Follow-up question: Is it only by convention that we shift the mantissa of the smaller number? Why not shift the bigger number down instead? $\endgroup$ Sep 5, 2019 at 20:12
  • $\begingroup$ @Jean-ClaudeArbaut Thanks! I just tried, and you're right. $\endgroup$ Sep 5, 2019 at 21:06
  • $\begingroup$ I am not sure the smaller number get rounded first, before addition. Say, the small number is 0.6355, and calculation is done with round-to-nearest, halfway-to-even. Doing rounding first before addition, we get 192.403 + 0.636 = 193.039. Result should really be 193.0385, halfway-rounded-down to 193.038 $\endgroup$ Sep 5, 2019 at 21:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .