<s>[INST] Two expressions using three-digit floating point arithmetic with rounding? What is the result of evaluating the following two expressions using three-digit floating point arithmetic with rounding?
$(113. + -111.) + 7.51$
$113. + (-111. + 7.51)$


*

*$9.51$ and $10.0$ respectively

*$10.0$ and $9.51$ respectively

*$9.51$ and $9.51$ respectively

*$10.0$ and $10.0$ respectively



My attempt :
$(113. + -111.) + 7.51 
= 2 + 7.51 
= 9.51$
$113. + (-111. + 7.51) 
= 113. + (-111. + 7.51) 
= 113. - 103. = 10$ [$103.49$ is rounded to $103.0$]


Can you explain more formally please ?

 [/INST] Recall that in $n$-digit floating-point arithmetic numbers are represented by a signed $n$-digit integer and an exponent. Rounding occurs when the significant digits of a number exceed $n$, in which case only the first $n$ are kept and the $n$th is adjusted according to the value of the $(n+1)$th.
You cannot get much more formal than what you did, but to make the computation (arguably) more clear you could rewrite all the involved numbers in scientific notation.
So we have
\begin{align*}
&\big(1.13 \cdot 10^2 + (-1.11 \cdot 10^2)\big) + 7.51 \cdot 10^0 \\&= 2 \cdot 10^0 + 7.51 \cdot 10^0 \\&= 9.51 \cdot 10^0.
\end{align*}
On the other hand
\begin{align*}
&1.13 \cdot 10^2 + (-1.11 \cdot 10^2 + 7.51 \cdot 10^0)\\ &= 1.13 \cdot 10^2 + \underbrace{(-1.0349 \cdot 10^2)}_{\text{rounded to } -1.03 \cdot 10^2} \\ &= 1 \cdot 10^1.
\end{align*}
</s>