0

Division method to find binary conversion from decimal

How can I write this in LaTeX? As I'm using codecogs to convert equations written in latex to a png file.

cgnieder
  • 66,645

1 Answers1

2

Here is a solution:

\documentclass{article}
\usepackage{array, calc}
\usepackage{old-arrows} 

\newcommand{\divstep}[1]%
{\setlength{\tabcolsep}{3pt}\setlength{\extrarowheight}{0pt}2~\begin{tabular}{|>{\centering}p{\widthof{9999}}}#1 \tabularnewline \hline\end{tabular}}% 

\begin{document}

\sffamily%
\setlength{\extrarowheight}{2pt}
\newcounter{rowctr}\setcounter{rowctr}{0}
\begin{tabular}{ >{\hspace*{\dimexpr(\therowctr pt)*3}\stepcounter{rowctr}}c>{\rule[0.6ex]{0.8cm}{0.6pt}~}ll}
\divstep{4215} &1 & $\longleftarrow$ LSB\\
 \divstep{2107} &1 \\
 \divstep{1053} &1 \\
 \divstep{526} &0 \\
 \divstep{263} &1 \\
 \divstep{131} &1 \\
 \divstep{65} & 1 \\
 \divstep{32} & 0 \\
 \divstep{16} & 0 \\
 \divstep{8} & 0 \\
 \divstep{4} & 0 \\
 \divstep{2} & 0 \\
 \divstep{1} & 1 & $\longleftarrow$ MSB\\
~ 0
\end{tabular}

\end{document} 

enter image description here

Bernard
  • 271,350