| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% longdiv.4ht 2009-05-21-09:32 % |
| 3 |
% Copyright (C) 2002--2009 Eitan M. Gurari % |
| 4 |
% % |
| 5 |
% This work may be distributed and/or modified under the % |
| 6 |
% conditions of the LaTeX Project Public License, either % |
| 7 |
% version 1.3c of this license or (at your option) any % |
| 8 |
% later version. The latest version of this license is % |
| 9 |
% in % |
| 10 |
% http://www.latex-project.org/lppl.txt % |
| 11 |
% and version 1.3c or later is part of all distributions % |
| 12 |
% of LaTeX version 2005/12/01 or later. % |
| 13 |
% % |
| 14 |
% This work has the LPPL maintenance status "maintained".% |
| 15 |
% % |
| 16 |
% This Current Maintainer of this work % |
| 17 |
% is Eitan M. Gurari. % |
| 18 |
% % |
| 19 |
% If you modify this program your changing its signature % |
| 20 |
% with a directive of the following form will be % |
| 21 |
% appreciated. % |
| 22 |
% \message{signature} % |
| 23 |
% % |
| 24 |
% [email protected] % |
| 25 |
% http://www.cse.ohio-state.edu/~gurari % |
| 26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 |
\immediate\write-1{version 2009-05-21-09:32} |
| 28 |
|
| 29 |
|
| 30 |
\def\longdiv#1#2{{% |
| 31 |
\def\showdig{\edef\temp{&{\the\scratch}}\temp\cr |
| 32 |
&{\the\rtot}\cr}% |
| 33 |
\global\rtot=#1\relax |
| 34 |
\count0=\rtot\divide\count0by#2\edef\quotient{\the\count0}% |
| 35 |
\def\temp##1{\ifx##1\temp\else \noexpand\dodig ##1\expandafter\temp\fi}% |
| 36 |
\edef\routine{\expandafter\temp\quotient\temp}% |
| 37 |
\def\dodig##1{\global\multiply\gpten |
| 38 |
by10\relax}\global\gpten=1\relax\routine |
| 39 |
\def\dodig##1{\global\divide\gpten by10\relax |
| 40 |
\scratch =\gpten |
| 41 |
\multiply\scratch by##1\relax |
| 42 |
\multiply\scratch by#2\relax |
| 43 |
\global\advance\rtot-\scratch \relax |
| 44 |
\ifnum\scratch>0 \showdig \fi |
| 45 |
}% |
| 46 |
\a:longdiv \long:div{#2}\b:longdiv |
| 47 |
}} |
| 48 |
\catcode`\#=13 |
| 49 |
\catcode`\@=6 |
| 50 |
\def\long:div@1{\halign{#&#\cr |
| 51 |
&\quotient\cr |
| 52 |
@1&\the\rtot\cr |
| 53 |
\routine \cr |
| 54 |
}} |
| 55 |
\catcode`\#=6 |
| 56 |
\catcode`\@=11 |
| 57 |
|
| 58 |
\NewConfigure{longdiv}{2} |
| 59 |
|
| 60 |
\Hinput{longdiv} |
| 61 |
\endinput |
| 62 |
|