Shark44
Shark44

Reputation: 803

LaTeX - Decimal to Binary conversion scheme

I'm trying to replicate on LaTeX the decimal to binary conversion scheme, which should look like this:
64 | 0
32 | 0
16 | 0
And so on, considering the vertical lines have to be connected, so no vertical space between them. Is there a way to do that? That's what I've got so far:

${56\newline28\newline14\newline7\newline3\newline1\newline0\newline}\vert\right{0\newline0\newline0\newline0\newline0\newline1\newline}$

Upvotes: 1

Views: 705

Answers (2)

Dimitris
Dimitris

Reputation: 579

A naive approach.

\begin{center}
\begin{tabular}{c|c|c|c}
Division by 2& Quotient & Remainder & Bit $\#$\\
\hline
11/2 & 5&1&0\\
5/2 &2& 1&1\\
2/2 &1& 0&2\\ 
1/2&0&1&3
\end{tabular}
\end{center}

For a systematic way see https://tex.stackexchange.com/questions/96399/how-can-i-illustrate-decimal-to-binary-conversion and the answers therein.

Upvotes: 0

You could use a tabular:

\documentclass{article}

\begin{document}

\begin{tabular}{c|c}
64 & 0\\
32 & 0\\
16 & 0\\ 
\end{tabular}

\end{document}

Upvotes: 2

Related Questions