Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
Did you ever figure this out? I am needing to do the exact same thing. –  nw. Sep 20 '11 at 1: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
add comment

migrated from stackoverflow.com Aug 28 '11 at 11:57

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

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

share|improve this answer
    
Thats so wonderful. I will try using the same approach. Thanks for sharing –  www.sapnaedu.in Sep 20 '11 at 22:55
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.