I can't figure out how to display a multiline addition in latex with carried numbers... Could anyone show me how to do this neatly?
I figured out how to do the numbers that are carried over by using \overset{}, but how do I get a shorter line between the added number and the result? Now it fills all the page from left to middle....
Here's the code (I just posted it like this since it didn't render with the math tags..):
\begin{align*}
& \overset{1}{\ }\overset{1}{{1}}\overset{1}{0}\overset{1}{{1}}1_{ 2}\\
+ & \ \ \ 111_{2}\\
\hline & 10010\end{align*}
Ok I figured I could just do this:
\begin{minipage}[t]{40pt}%
\begin{align*}
& \overset{1}{\ }\overset{1}{{1}}\overset{1}{0}\overset{1}{{1}}1_{ 2}\\
+ & \ \ \ 111_{2}\\
\hline & 10010\end{align*}
%
\end{minipage}
Not the most elegant solution, so if anyone has a better way to do this (there must be, this is simple maths!!:P)...
Simple maths doesn't necessarily mean simple LaTeX! This is also not elegant LaTeX, but it produces a fairly neat result:
$\displaystyle \begin{array}{c@{\:}c@{\:}c@{\:}c@{\:}c@{\,}c}Code:\begin{array}{c@{\:}c@{\:}c@{\:}c@{\:}c@{\,}c} ^{^1}&^{^1}&^{^1}&^{^1}\vspace{-2ex}\\ &1&0&1&1&_2\\ \llap{+}&&1&1&1&_2\\ \hline 1&0&0&1&0\\ \end{array}
^{^1}&^{^1}&^{^1}&^{^1}\vspace{-2ex}\\
&1&0&1&1&_2\\
\llap{+}&&1&1&1&_2\\
\hline
1&0&0&1&0\\
\end{array}
$
While we're on it. I modified the above for subtraction:
$\displaystyle \begin{array}{c@{\:}c@{\:}c@{\:}c@{\:}c@{\:}c@{\:} c@{\:}c@{\,}c} ^{^{}}&^{^{}}&^{^{}}&^{^{10}}&^{^{10}}&^{^{10}}&^{ ^{10}}\vspace{-2ex}\\
1&0&1&1&0&0&0&_2\\
\llap{-}0&0&0&1&0&1&1&_2\\
\hline
1&0&0&1&1&0&1_2\\
\end{array}$
But how would I be able to show that the borrowed 10's are striked out? I tried with \sout{}, but that oddly enough adds a line under the number instead of through...