11

I am writing a report in Latex and need to represent the CRC computation. So basically, I need to show the Paper-n-Pencil Method of Long Division in LaTeX.

Any idea how I can approach this problem ? Any good reference would be highly appreciated.

I plan to write similar thing in LaTeX.

CRC Computation

lockstep
  • 250,273
  • Did you ever figure this out? I am needing to do the exact same thing. – nw. Sep 20 '11 at 01:33
  • sorry, I couldn't do in latex atleast. I computed in the paper and developed it in inkscape – www.sapnaedu.in Sep 20 '11 at 12:31
  • OK, well I found somewhat of a solution, which I will post here for others' reference. It's not elegant (have to do the division by hand) but good enough for my purposes. – nw. Sep 20 '11 at 16:25

2 Answers2

5

Per this article, I ended up doing this:


\newdimen\digitwidth
\settowidth\digitwidth{0}
\def~{\hspace{\digitwidth}}


\def\divrule#1#2{%
\noalign{\moveright#1\digitwidth%
\vbox{\hrule width#2\digitwidth}}}
101\,\begin{tabular}[b]{@{}r@{}}
10010 \\ \hline
\big)\begin{tabular}[t]{@{}l@{}}
1011110 \101 \\ \divrule{0}{7}
~~~111 \~~~101 \\ \divrule{3}{4}
~~~~100
\end{tabular}
\end{tabular}

You have to do the division by hand, then use '~'s for aligning the digits. For the little bars, do \divrule{startPosition}{length}.

Example output:
enter image description here

nw.
  • 612
4

I've never used it myself, but you might try this package. It would likely require modification for binary, though.

There is also this post.

rogerl
  • 3,583
  • 5
  • 29
  • 39