¼ýÀÚ¸¦ ¹®ÀÚ·Î ¹Ù²Ù¾î µ¡¼ÀÀ» Èä³»³À´Ï´Ù. µû¶ó¼ TeXÀÇ ¿¬»ê ÇÑ°è¿Í´Â »ó°ü¾÷½À´Ï´Ù.
¾Æ·¡ÀÇ Äڵ带 ¿¹¸¦ µé¾î ¼³¸íÇϸé, \add{187}{456}
- ÁÖ¾îÁø ÇÇ¿¬»êÀÚ¸¦ °¢°¢ µÚÁý´Â´Ù.
187 ==> 781 456 ==> 654
- µÚÁýÀº ÇÇ¿¬»çÀÚ¸¦ ¸Ç¾ÕºÎÅÍ ´õÇسª°£´Ù. ¿Ã¸²ÀÌ ¹ß»ýÇÏ¸é ´ÙÀ½À¸·Î ³Ñ±ä´Ù.
7 8 1 + + + 6 5 4 ===> 346 + + 1 1 <-- ¿Ã¸²
- °á°ú¸¦ ´Ù½Ã µÚÁý´Ï´Ù.
346 ==> 643
¾Æ·¡ÀÇ Äڵ带 test.tex Á¤µµ·Î ÀúÀåÇÑ ÈÄ, Ç÷¹ÀÎÅØ ¸í·ÉÀ¸·Î tex test ·Î test.dvi¸¦ ¾ò½À´Ï´Ù.
%%% ¸ÅÅ©·Î ½ÃÀÛ
%%
\let\ea\expandafter
\newtoks\list
\newif\ifcontinue
\newcount\x \newcount\y \newcount\p
\def\fifo#1{\ifx\ofif#1\ofif\fi\process#1\fifo}
\def\ofif#1\fifo{\fi}
\def\lifo#1#2{\ifx\ofil#2 #1\ofil\fi\lifo{#2#1}}
\def\ofil#1\lifo#2{\fi}
\def\push#1{\edef\act{\noexpand\list={#1 \the\list}}\act}
\def\carry#1{\ifnum#1>9 \advance#1-10 \p=1 \else \p=0 \fi
\ea\push\number#1}
\def\nxte#1#2{
\def\pop##1##2\pop{\gdef#1{##2}\gdef#2{##1}}
\ea\pop#1\pop}
\def\xadd#1#2{\continuetrue
\loop
\ifx#1\empty\continuefalse\fi \ifx#2\empty\continuefalse\fi
\ifcontinue \nxte#1\nxtt \nxte#2\nxtu
\x=\nxtt \y=\nxtu \advance\x by\y \advance\x by\p \carry\x
\repeat
\let\opnd\opndn \ifx#1\empty \let\opnd\opndt \fi
\def\process##1{\y=##1 \advance\y by\p \carry\y}
\ea\fifo\opnd\ofif \ifnum\p=0 \else\number\p \fi}
\def\add#1#2{\list={}
\edef\opndn{\ea\lifo#1\ofil} \edef\opndt{\ea\lifo#2\ofil}
\xadd\opndn\opndt
\def\process##1{##1}\ea\fifo\the\list\ofif}
%%
%%% ¸ÅÅ©·Î ³¡
\def\foo{1129387423947923092384095783471029470395703492}
\def\bar{839583095823984723842734629852983472938472938473298}
\add{2}{3}
\add \foo\bar
\add\bar\foo
\add\foo{763823876}
\add{672687687612123587687828374682372468237982376525818763423846932846}\foo
\bye