0

I have the following code to show binary addition of two numbers:

\documentclass{article}
\begin{document}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{lllll}
      & 1 & 0 & 0 & 1 \\
    + & 1 & 1 & 0 & 0 \\
    \hline
    1 & 0 & 1 & 0 & 1 \\
    \hline
\end{tabular}
\end{document}

I want to be able to indicate the overflow to the reader somehow. 2 ideas that I have in mind are presented below:

1. Underbraces

enter image description here

2. Boxing the overflown bit

enter image description here

EDIT: User Ivan pointed out that using fbox{1} would do it and it works perfectly. But I would still like to know how to put underbraces. Thanks!

3

1 Answer 1

2

After checking out the post linked in the comments I have decided on the following solution:

\documentclass{article}

\begin{document}
\begin{table}[h]\centering
    \begin{tabular}{cllll}
            & 1 & 0 & 0 & 1 \\
        $+$ & 1 & 1 & 0 & 0 \\
        \hline
       \fbox{1} & 0 & 1 & 0 & 1 \\
        \hline \\[-3ex]
        & \multicolumn{4}{c}{\upbracefill} \\
        & \multicolumn{4}{c}{\small significant bits}
    \end{tabular}
\end{table}
\end{document}

which produces basically what I want: enter image description here

If the box is a little too close to the hrule s then you can increase the row separation using \renewcommand{\arraystretch}{...} and adjust the \\[] lengths accordingly!

You must log in to answer this question.

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