2

I have posted this and this later item on long division.

I thought what appears below worked perfectly. But only today I tried it with an example that has several digits before the decimal point in the quotient, and it's lousy.

So I have two questions:

  • How do we make it work well with several digits before the decimal point in the quotient? This I could possibly figure out with further skull sweat, but I am reluctant to undertake that without a good answer to the next question, which goes beyond my present competence.

  • How do we make it into a user-friendly style file, so the user only needs to enter the numbers with some indication of what the role of each of them is in the long-division process?

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
% \usepackage{xcolor}
\usepackage{array, booktabs}
\parindent=0pt
\pagestyle{empty}

\begin{document}

\[
\begin{array}{ rr@{} %>{\color{red}}
c@{}*{6}{c@{\mkern2mu}} }
& 0 & . & 7 & 1 & 6 & 2 \\ \cmidrule[0.6pt](l{-0.385em}){2-8}\\[-16.9pt]
74\;\rlap{\Large)} &53 & . & 0 & 0 & 0 & 0 & 0 \\
& 51 & & 8 \\ \cmidrule(l{1ex}){2-5}
& 1 & & 2 & 0 \\
& & & 7 & 4 \\ \cmidrule{3-6}
& & & 4 & 6 & 0 \\
& & & 4 & 4 & 4 \\ \cmidrule{4-7}
& & & & 1 & 6 & 0 \\
& & & & 1 & 4 & 8 \\ \cmidrule{5-8}
& & & & & 1 & 2 & 0
\end{array}
\]

\[
\begin{array}{ rr@{} %>{\color{red}}
c@{}*{8}{c@{\mkern2mu}} }
& 101 & . & 8 & 0 & 2 & 0 & 8 & 3 \\ \cmidrule[0.6pt](l{-0.385em}){2-8}\\    [-16.9pt]
96\;\rlap{\Large)} &9773 & . & 0 & 0 & 0 & 0 & 0 \\
& 96\phantom{00} & &  \\ \cmidrule(l{1ex}){2-2}
& 17\phantom{0} & & \\
&  0\phantom{0} \\ \cmidrule(l{1ex}){2-2}
& 173 \\
&  96 \\ \cmidrule(l{1ex}){2-3}
& 77 & & 0 \\
& 76& & 8 \\ \cmidrule(l{1ex}){2-4}
& & & 2 & 0 \\
& & & & 0 \\ \cmidrule{3-5}
& & & 2 & 0 & 0 \\
& & & 1 & 9 & 2 \\ \cmidrule{3-6}
& & & & & 8 & 0 \\
& & & & & & 0 \\ \cmidrule{6-7}
& & & & & 8 & 0 & 0 \\
& & & & & 7 & 6 & 8 \\ \cmidrule{6-8}
& & & & & & 3 & 2 & 0 \\
& & & & & & 2 & 8 & 8 \\ \cmidrule{7-9}
& & & & & & & 3 & 2 & 0
\end{array}
\]

\end{document}
4
  • Did you try the longdiv package?
    – Bernard
    Commented May 17, 2018 at 21:47
  • by my knowledge, longdivonly does integers Commented May 17, 2018 at 22:15
  • @Bernard : I just tried it now. And I think I've tried it before, and it's lousy. Not only does it stop at the decimal point, but it show trailing 0s down to the units' place in every product, and it disallows deliberate insertion of wrong answers. Commented May 17, 2018 at 22:31
  • There's also xlop, but it's not internationalised yet, and for now is only adapted to the French way to make long divisions.
    – Bernard
    Commented May 17, 2018 at 22:46

1 Answer 1

1

I had to do a long division for a Dutch textbook on digital design. I also used this method to do a long division on binary numbers. The trick is to use hidden character to indent numbers to the right position. The macro \ph{} takes care of this. Note that the comments are in Dutch:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage{xcolor}

%% Print hidden characters by using the white color, used for aligning numbers.
%% Please note that the dash must cast to mathbin. See:
%% http://tex.stackexchange.com/questions/21598/how-to-color-math-symbols
\newcommand\ph[1]{\if-#1\mathbin{\textcolor{white}{-}}\else\textcolor{white}{#1}\fi}

\begin{document}

\begin{equation*}
\setlength{\jot}{0pt}
\begin{split}
                                  &12345.67 \div 25 = 493.8268 \leftrightarrow \text{quoti\"ent}\\
\text{viermaal aftrekken}\qquad  &\underline{100}\ - \\
                                  &\ph{0}234 \\
\text{negenmaal aftrekken}\qquad &\ph{0}\underline{225}\ - \\
                                  &\ph{000}95 \\
\text{driemaal aftrekken}\qquad  &\ph{000}\underline{75}\ - \\
                                  &\ph{000} 20\ph{.}6 \\
\text{achtmaal aftrekken}\qquad  &\ph{000}\underline{20\ph{.}0}\ - \\
                                  &\ph{00000.}67 \\
\text{tweemaal aftrekken}\qquad  &\ph{00000.}\underline{50}\ - \\
                                  &\ph{00000.}170 \\
\text{zesmaal aftrekken}\qquad   &\ph{00000.}\underline{150}\ - \\
                                  &\ph{00000.0}200 \\
\text{achtmaal aftrekken}\qquad  &\ph{00000.0}\underline{200}\ - \\
                                  &\ph{00000.000}0 \leftrightarrow \text{rest} \\
\end{split}
\end{equation*}

\end{document}

You must log in to answer this question.

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