Debian Codegraph @

texmf-dist/tex/generic/bigintcalc/bigintcalc.sty

raw
1 %%
2 %% This is file `bigintcalc.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% bigintcalc.dtx (with options: `package')
8 %%
9 %% This is a generated file.
10 %%
11 %% Project: bigintcalc
12 %% Version: 2019/12/15 v1.5
13 %%
14 %% Copyright (C)
15 %% 2007, 2011, 2012 Heiko Oberdiek
16 %% 2016-2019 Oberdiek Package Support Group
17 %%
18 %% This work may be distributed and/or modified under the
19 %% conditions of the LaTeX Project Public License, either
20 %% version 1.3c of this license or (at your option) any later
21 %% version. This version of this license is in
22 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
23 %% and the latest version of this license is in
24 %% https://www.latex-project.org/lppl.txt
25 %% and version 1.3 or later is part of all distributions of
26 %% LaTeX version 2005/12/01 or later.
27 %%
28 %% This work has the LPPL maintenance status "maintained".
29 %%
30 %% The Current Maintainers of this work are
31 %% Heiko Oberdiek and the Oberdiek Package Support Group
32 %% https://github.com/ho-tex/bigintcalc/issues
33 %%
34 %%
35 %% The Base Interpreter refers to any `TeX-Format',
36 %% because some files are installed in TDS:tex/generic//.
37 %%
38 %% This work consists of the main source file bigintcalc.dtx
39 %% and the derived files
40 %% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv,
41 %% bigintcalc-test1.tex, bigintcalc-test2.tex,
42 %% bigintcalc-test3.tex.
43 %%
44 \begingroup\catcode61\catcode48\catcode32=10\relax%
45 \catcode13=5 % ^^M
46 \endlinechar=13 %
47 \catcode35=6 % #
48 \catcode39=12 % '
49 \catcode44=12 % ,
50 \catcode45=12 % -
51 \catcode46=12 % .
52 \catcode58=12 % :
53 \catcode64=11 % @
54 \catcode123=1 % {
55 \catcode125=2 % }
56 \expandafter\let\expandafter\x\csname [email protected]\endcsname
57 \ifx\x\relax % plain-TeX, first loading
58 \else
59 \def\empty{}%
60 \ifx\x\empty % LaTeX, first loading,
61 % variable is initialized, but \ProvidesPackage not yet seen
62 \else
63 \expandafter\ifx\csname PackageInfo\endcsname\relax
64 \def\x#1#2{%
65 \immediate\write-1{Package #1 Info: #2.}%
66 }%
67 \else
68 \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
69 \fi
70 \x{bigintcalc}{The package is already loaded}%
71 \aftergroup\endinput
72 \fi
73 \fi
74 \endgroup%
75 \begingroup\catcode61\catcode48\catcode32=10\relax%
76 \catcode13=5 % ^^M
77 \endlinechar=13 %
78 \catcode35=6 % #
79 \catcode39=12 % '
80 \catcode40=12 % (
81 \catcode41=12 % )
82 \catcode44=12 % ,
83 \catcode45=12 % -
84 \catcode46=12 % .
85 \catcode47=12 % /
86 \catcode58=12 % :
87 \catcode64=11 % @
88 \catcode91=12 % [
89 \catcode93=12 % ]
90 \catcode123=1 % {
91 \catcode125=2 % }
92 \expandafter\ifx\csname ProvidesPackage\endcsname\relax
93 \def\x#1#2#3[#4]{\endgroup
94 \immediate\write-1{Package: #3 #4}%
95 \xdef#1{#4}%
96 }%
97 \else
98 \def\x#1#2[#3]{\endgroup
99 #2[{#3}]%
100 \ifx#1\@undefined
101 \xdef#1{#3}%
102 \fi
103 \ifx#1\relax
104 \xdef#1{#3}%
105 \fi
106 }%
107 \fi
108 \expandafter\x\csname [email protected]\endcsname
109 \ProvidesPackage{bigintcalc}%
110 [2019/12/15 v1.5 Expandable calculations on big integers (HO)]%
111 \begingroup\catcode61\catcode48\catcode32=10\relax%
112 \catcode13=5 % ^^M
113 \endlinechar=13 %
114 \catcode123=1 % {
115 \catcode125=2 % }
116 \catcode64=11 % @
117 \def\x{\endgroup
118 \expandafter\edef\csname BIC@AtEnd\endcsname{%
119 \endlinechar=\the\endlinechar\relax
120 \catcode13=\the\catcode13\relax
121 \catcode32=\the\catcode32\relax
122 \catcode35=\the\catcode35\relax
123 \catcode61=\the\catcode61\relax
124 \catcode64=\the\catcode64\relax
125 \catcode123=\the\catcode123\relax
126 \catcode125=\the\catcode125\relax
127 }%
128 }%
129 \x\catcode61\catcode48\catcode32=10\relax%
130 \catcode13=5 % ^^M
131 \endlinechar=13 %
132 \catcode35=6 % #
133 \catcode64=11 % @
134 \catcode123=1 % {
135 \catcode125=2 % }
136 \def\TMP@EnsureCode#1#2{%
137 \edef\BIC@AtEnd{%
138 \BIC@AtEnd
139 \catcode#1=\the\catcode#1\relax
140 }%
141 \catcode#1=#2\relax
142 }
143 \TMP@EnsureCode{33}{12}% !
144 \TMP@EnsureCode{36}{14}% $ (comment!)
145 \TMP@EnsureCode{38}{14}% & (comment!)
146 \TMP@EnsureCode{40}{12}% (
147 \TMP@EnsureCode{41}{12}% )
148 \TMP@EnsureCode{42}{12}% *
149 \TMP@EnsureCode{43}{12}% +
150 \TMP@EnsureCode{45}{12}% -
151 \TMP@EnsureCode{46}{12}% .
152 \TMP@EnsureCode{47}{12}% /
153 \TMP@EnsureCode{58}{11}% : (letter!)
154 \TMP@EnsureCode{60}{12}% <
155 \TMP@EnsureCode{62}{12}% >
156 \TMP@EnsureCode{63}{14}% ? (comment!)
157 \TMP@EnsureCode{91}{12}% [
158 \TMP@EnsureCode{93}{12}% ]
159 \edef\BIC@AtEnd{\BIC@AtEnd\noexpand\endinput}
160 \begingroup\expandafter\expandafter\expandafter\endgroup
161 \expandafter\ifx\csname BIC@TestMode\endcsname\relax
162 \else
163 \catcode63=9 % ? (ignore)
164 \fi
165 ? \let\BIC@@TestMode\BIC@TestMode
166 \begingroup\expandafter\expandafter\expandafter\endgroup
167 \expandafter\ifx\csname numexpr\endcsname\relax
168 \catcode36=9 % $ (ignore)
169 \else
170 \catcode38=9 % & (ignore)
171 \fi
172 \let\BIC@Fi\fi
173 \def\BIC@AfterFi#1#2\BIC@Fi{\fi#1}%
174 \def\BIC@AfterFiFi#1#2\BIC@Fi{\fi\fi#1}%
175 \def\BIC@AfterFiFiFi#1#2\BIC@Fi{\fi\fi\fi#1}%
176 \begingroup
177 \def\x#1{\endgroup
178 \let\BIC@Space= #1%
179 }%
180 \x{ }
181 \begingroup\expandafter\expandafter\expandafter\endgroup
182 \expandafter\ifx\csname RequirePackage\endcsname\relax
183 \def\TMP@RequirePackage#1[#2]{%
184 \begingroup\expandafter\expandafter\expandafter\endgroup
185 \expandafter\ifx\csname ver@#1.sty\endcsname\relax
186 \input #1.sty\relax
187 \fi
188 }%
189 \TMP@RequirePackage{pdftexcmds}[2007/11/11]%
190 \else
191 \RequirePackage{pdftexcmds}[2007/11/11]%
192 \fi
193 \begingroup\expandafter\expandafter\expandafter\endgroup
194 \expandafter\ifx\csname pdf@escapehex\endcsname\relax
195 \def\BIC@Expand#1{%
196 \romannumeral0%
197 \BIC@@Expand#1!\@nil{}%
198 }%
199 \def\BIC@@Expand#1#2\@nil#3{%
200 \expandafter\ifcat\noexpand#1\relax
201 \expandafter\@firstoftwo
202 \else
203 \expandafter\@secondoftwo
204 \fi
205 {%
206 \expandafter\BIC@@Expand#1#2\@nil{#3}%
207 }{%
208 \ifx#1!%
209 \expandafter\@firstoftwo
210 \else
211 \expandafter\@secondoftwo
212 \fi
213 { #3}{%
214 \BIC@@Expand#2\@nil{#3#1}%
215 }%
216 }%
217 }%
218 \expandafter\ifx\csname @firstoftwo\endcsname\relax
219 \long\def\@firstoftwo#1#2{#1}%
220 \fi
221 \expandafter\ifx\csname @secondoftwo\endcsname\relax
222 \long\def\@secondoftwo#1#2{#2}%
223 \fi
224 \else
225 \def\BIC@Expand#1{%
226 \romannumeral0\expandafter\expandafter\expandafter\BIC@Space
227 \pdf@unescapehex{%
228 \expandafter\expandafter\expandafter
229 \BIC@StripHexSpace\pdf@escapehex{#1}20\@nil
230 }%
231 }%
232 \def\BIC@StripHexSpace#120#2\@nil{%
233 #1%
234 \ifx\\#2\\%
235 \else
236 \BIC@AfterFi{%
237 \BIC@StripHexSpace#2\@nil
238 }%
239 \BIC@Fi
240 }%
241 \fi
242 \def\BIC@Normalize#1#2{%
243 \ifx#2-%
244 \ifx\\#1\\%
245 \BIC@AfterFiFi{%
246 \BIC@Normalize-%
247 }%
248 \else
249 \BIC@AfterFiFi{%
250 \BIC@Normalize{}%
251 }%
252 \fi
253 \else
254 \ifx#2+%
255 \BIC@AfterFiFi{%
256 \BIC@Normalize{#1}%
257 }%
258 \else
259 \ifx#20%
260 \BIC@AfterFiFiFi{%
261 \BIC@NormalizeZero{#1}%
262 }%
263 \else
264 \BIC@AfterFiFiFi{%
265 \BIC@NormalizeDigits#1#2%
266 }%
267 \fi
268 \fi
269 \BIC@Fi
270 }
271 \def\BIC@NormalizeZero#1#2{%
272 \ifx#2!%
273 \BIC@AfterFi{ 0}%
274 \else
275 \ifx#20%
276 \BIC@AfterFiFi{%
277 \BIC@NormalizeZero{#1}%
278 }%
279 \else
280 \BIC@AfterFiFi{%
281 \BIC@NormalizeDigits#1#2%
282 }%
283 \fi
284 \BIC@Fi
285 }
286 \def\BIC@NormalizeDigits#1!{ #1}
287 \def\bigintcalcNum#1{%
288 \romannumeral0%
289 \expandafter\expandafter\expandafter\BIC@Normalize
290 \expandafter\expandafter\expandafter{%
291 \expandafter\expandafter\expandafter}%
292 \BIC@Expand{#1}!%
293 }
294 \def\bigintcalcInv#1{%
295 \romannumeral0\expandafter\expandafter\expandafter\BIC@Space
296 \bigintcalcNum{-#1}%
297 }
298 \def\bigintcalcAbs#1{%
299 \romannumeral0%
300 \expandafter\expandafter\expandafter\BIC@Abs
301 \bigintcalcNum{#1}%
302 }
303 \def\BIC@Abs#1{%
304 \ifx#1-%
305 \expandafter\BIC@Space
306 \else
307 \expandafter\BIC@Space
308 \expandafter#1%
309 \fi
310 }
311 \def\bigintcalcSgn#1{%
312 \number
313 \expandafter\expandafter\expandafter\BIC@Sgn
314 \bigintcalcNum{#1}! %
315 }
316 \def\BIC@Sgn#1#2!{%
317 \ifx#1-%
318 -1%
319 \else
320 \ifx#10%
321 0%
322 \else
323 1%
324 \fi
325 \fi
326 }
327 \def\bigintcalcCmp#1#2{%
328 \number
329 \expandafter\expandafter\expandafter\BIC@Cmp
330 \bigintcalcNum{#2}!{#1}%
331 }
332 \def\BIC@Cmp#1!#2{%
333 \expandafter\expandafter\expandafter\BIC@@Cmp
334 \bigintcalcNum{#2}!#1!%
335 }
336 \def\BIC@@Cmp#1#2!#3#4!{%
337 \ifx#1-%
338 \ifx#3-%
339 \BIC@AfterFiFi{%
340 \BIC@@Cmp#4!#2!%
341 }%
342 \else
343 \BIC@AfterFiFi{%
344 -1 %
345 }%
346 \fi
347 \else
348 \ifx#3-%
349 \BIC@AfterFiFi{%
350 1 %
351 }%
352 \else
353 \BIC@AfterFiFi{%
354 \BIC@CmpLength#1#2!#3#4!#1#2!#3#4!%
355 }%
356 \fi
357 \BIC@Fi
358 }
359 \def\BIC@PosCmp#1!#2!{%
360 \BIC@CmpLength#1!#2!#1!#2!%
361 }
362 \def\BIC@CmpLength#1#2!#3#4!{%
363 \ifx\\#2\\%
364 \ifx\\#4\\%
365 \BIC@AfterFiFi\BIC@CmpDiff
366 \else
367 \BIC@AfterFiFi{%
368 \BIC@CmpResult{-1}%
369 }%
370 \fi
371 \else
372 \ifx\\#4\\%
373 \BIC@AfterFiFi{%
374 \BIC@CmpResult1%
375 }%
376 \else
377 \BIC@AfterFiFi{%
378 \BIC@CmpLength#2!#4!%
379 }%
380 \fi
381 \BIC@Fi
382 }
383 \def\BIC@CmpResult#1#2!#3!{#1 }
384 \def\BIC@CmpDiff#1#2!#3#4!{%
385 \ifnum#1<#3 %
386 \BIC@AfterFi{%
387 -1 %
388 }%
389 \else
390 \ifnum#1>#3 %
391 \BIC@AfterFiFi{%
392 1 %
393 }%
394 \else
395 \ifx\\#2\\%
396 \BIC@AfterFiFiFi{%
397 0 %
398 }%
399 \else
400 \BIC@AfterFiFiFi{%
401 \BIC@CmpDiff#2!#4!%
402 }%
403 \fi
404 \fi
405 \BIC@Fi
406 }
407 \def\bigintcalcMin#1{%
408 \romannumeral0%
409 \expandafter\expandafter\expandafter\BIC@MinMax
410 \bigintcalcNum{#1}!-!%
411 }
412 \def\bigintcalcMax#1{%
413 \romannumeral0%
414 \expandafter\expandafter\expandafter\BIC@MinMax
415 \bigintcalcNum{#1}!!%
416 }
417 \def\BIC@MinMax#1!#2!#3{%
418 \expandafter\expandafter\expandafter\BIC@@MinMax
419 \bigintcalcNum{#3}!#1!#2!%
420 }
421 \def\BIC@@MinMax#1!#2!#3!{%
422 \ifnum\BIC@@Cmp#1!#2!=#31 %
423 \BIC@AfterFi{ #1}%
424 \else
425 \BIC@AfterFi{ #2}%
426 \BIC@Fi
427 }
428 \def\bigintcalcOdd#1{%
429 \romannumeral0%
430 \expandafter\expandafter\expandafter\BIC@Odd
431 \bigintcalcAbs{#1}!%
432 }
433 \def\BigIntCalcOdd#1!{%
434 \romannumeral0%
435 \BIC@Odd#1!%
436 }
437 \def\BIC@Odd#1#2{%
438 \ifx#2!%
439 \ifodd#1 %
440 \BIC@AfterFiFi{ 1}%
441 \else
442 \BIC@AfterFiFi{ 0}%
443 \fi
444 \else
445 \expandafter\BIC@Odd\expandafter#2%
446 \BIC@Fi
447 }
448 \def\bigintcalcInc#1{%
449 \romannumeral0%
450 \expandafter\expandafter\expandafter\BIC@IncSwitch
451 \bigintcalcNum{#1}!%
452 }
453 \def\BIC@IncSwitch#1#2!{%
454 \ifcase\BIC@@Cmp#1#2!-1!%
455 \BIC@AfterFi{ 0}%
456 \or
457 \BIC@AfterFi{%
458 \BIC@Inc#1#2!{}%
459 }%
460 \else
461 \BIC@AfterFi{%
462 \expandafter-\romannumeral0%
463 \BIC@Dec#2!{}%
464 }%
465 \BIC@Fi
466 }
467 \def\bigintcalcDec#1{%
468 \romannumeral0%
469 \expandafter\expandafter\expandafter\BIC@DecSwitch
470 \bigintcalcNum{#1}!%
471 }
472 \def\BIC@DecSwitch#1#2!{%
473 \ifcase\BIC@Sgn#1#2! %
474 \BIC@AfterFi{ -1}%
475 \or
476 \BIC@AfterFi{%
477 \BIC@Dec#1#2!{}%
478 }%
479 \else
480 \BIC@AfterFi{%
481 \expandafter-\romannumeral0%
482 \BIC@Inc#2!{}%
483 }%
484 \BIC@Fi
485 }
486 \def\BigIntCalcInc#1!{%
487 \romannumeral0\BIC@Inc#1!{}%
488 }
489 \def\BigIntCalcDec#1!{%
490 \romannumeral0\BIC@Dec#1!{}%
491 }
492 \def\BIC@Inc#1#2!#3{%
493 \ifx\\#2\\%
494 \BIC@AfterFi{%
495 \BIC@@Inc1#1#3!{}%
496 }%
497 \else
498 \BIC@AfterFi{%
499 \BIC@Inc#2!{#1#3}%
500 }%
501 \BIC@Fi
502 }
503 \def\BIC@@Inc#1#2#3!#4{%
504 \ifcase#1 %
505 \ifx\\#3\\%
506 \BIC@AfterFiFi{ #2#4}%
507 \else
508 \BIC@AfterFiFi{%
509 \BIC@@Inc0#3!{#2#4}%
510 }%
511 \fi
512 \else
513 \ifnum#2<9 %
514 \BIC@AfterFiFi{%
515 & \expandafter\BIC@@@Inc\the\numexpr#2+1\relax
516 $ \expandafter\expandafter\expandafter\BIC@@@Inc
517 $ \ifcase#2 \expandafter1%
518 $ \or\expandafter2%
519 $ \or\expandafter3%
520 $ \or\expandafter4%
521 $ \or\expandafter5%
522 $ \or\expandafter6%
523 $ \or\expandafter7%
524 $ \or\expandafter8%
525 $ \or\expandafter9%
526 $? \else\BigIntCalcError:ThisCannotHappen%
527 $ \fi
528 0#3!{#4}%
529 }%
530 \else
531 \BIC@AfterFiFi{%
532 \BIC@@@Inc01#3!{#4}%
533 }%
534 \fi
535 \BIC@Fi
536 }
537 \def\BIC@@@Inc#1#2#3!#4{%
538 \ifx\\#3\\%
539 \ifnum#2=1 %
540 \BIC@AfterFiFi{ 1#1#4}%
541 \else
542 \BIC@AfterFiFi{ #1#4}%
543 \fi
544 \else
545 \BIC@AfterFi{%
546 \BIC@@Inc#2#3!{#1#4}%
547 }%
548 \BIC@Fi
549 }
550 \def\BIC@Dec#1#2!#3{%
551 \ifx\\#2\\%
552 \BIC@AfterFi{%
553 \BIC@@Dec1#1#3!{}%
554 }%
555 \else
556 \BIC@AfterFi{%
557 \BIC@Dec#2!{#1#3}%
558 }%
559 \BIC@Fi
560 }
561 \def\BIC@@Dec#1#2#3!#4{%
562 \ifcase#1 %
563 \ifx\\#3\\%
564 \BIC@AfterFiFi{ #2#4}%
565 \else
566 \BIC@AfterFiFi{%
567 \BIC@@Dec0#3!{#2#4}%
568 }%
569 \fi
570 \else
571 \ifnum#2>0 %
572 \BIC@AfterFiFi{%
573 & \expandafter\BIC@@@Dec\the\numexpr#2-1\relax
574 $ \expandafter\expandafter\expandafter\BIC@@@Dec
575 $ \ifcase#2
576 $? \BigIntCalcError:ThisCannotHappen%
577 $ \or\expandafter0%
578 $ \or\expandafter1%
579 $ \or\expandafter2%
580 $ \or\expandafter3%
581 $ \or\expandafter4%
582 $ \or\expandafter5%
583 $ \or\expandafter6%
584 $ \or\expandafter7%
585 $ \or\expandafter8%
586 $? \else\BigIntCalcError:ThisCannotHappen%
587 $ \fi
588 0#3!{#4}%
589 }%
590 \else
591 \BIC@AfterFiFi{%
592 \BIC@@@Dec91#3!{#4}%
593 }%
594 \fi
595 \BIC@Fi
596 }
597 \def\BIC@@@Dec#1#2#3!#4{%
598 \ifx\\#3\\%
599 \ifcase#1 %
600 \ifx\\#4\\%
601 \BIC@AfterFiFiFi{ 0}%
602 \else
603 \BIC@AfterFiFiFi{ #4}%
604 \fi
605 \else
606 \BIC@AfterFiFi{ #1#4}%
607 \fi
608 \else
609 \BIC@AfterFi{%
610 \BIC@@Dec#2#3!{#1#4}%
611 }%
612 \BIC@Fi
613 }
614 \def\bigintcalcAdd#1{%
615 \romannumeral0%
616 \expandafter\expandafter\expandafter\BIC@Add
617 \bigintcalcNum{#1}!%
618 }
619 \def\BIC@Add#1!#2{%
620 \expandafter\expandafter\expandafter
621 \BIC@AddSwitch\bigintcalcNum{#2}!#1!%
622 }
623 \def\bigintcalcSub#1#2{%
624 \romannumeral0%
625 \expandafter\expandafter\expandafter\BIC@Add
626 \bigintcalcNum{-#2}!{#1}%
627 }
628 \def\BIC@AddSwitch#1#2!#3#4!{%
629 \ifx#1-% x < 0
630 \ifx#3-% y < 0
631 \expandafter-\romannumeral0%
632 \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y
633 \BIC@AfterFiFiFi{%
634 \BIC@AddXY#2!#4!!!%
635 }%
636 \else % -x <= -y
637 \BIC@AfterFiFiFi{%
638 \BIC@AddXY#4!#2!!!%
639 }%
640 \fi
641 \else % y >= 0
642 \ifcase\BIC@PosCmp#2!#3#4!% -x = y
643 \BIC@AfterFiFiFi{ 0}%
644 \or % -x > y
645 \expandafter-\romannumeral0%
646 \BIC@AfterFiFiFi{%
647 \BIC@SubXY#2!#3#4!!!%
648 }%
649 \else % -x <= y
650 \BIC@AfterFiFiFi{%
651 \BIC@SubXY#3#4!#2!!!%
652 }%
653 \fi
654 \fi
655 \else % x >= 0
656 \ifx#3-% y < 0
657 \ifcase\BIC@PosCmp#1#2!#4!% x = -y
658 \BIC@AfterFiFiFi{ 0}%
659 \or % x > -y
660 \BIC@AfterFiFiFi{%
661 \BIC@SubXY#1#2!#4!!!%
662 }%
663 \else % x <= -y
664 \expandafter-\romannumeral0%
665 \BIC@AfterFiFiFi{%
666 \BIC@SubXY#4!#1#2!!!%
667 }%
668 \fi
669 \else % y >= 0
670 \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y
671 \BIC@AfterFiFiFi{%
672 \BIC@AddXY#1#2!#3#4!!!%
673 }%
674 \else % x <= y
675 \BIC@AfterFiFiFi{%
676 \BIC@AddXY#3#4!#1#2!!!%
677 }%
678 \fi
679 \fi
680 \BIC@Fi
681 }
682 \def\BigIntCalcAdd#1!#2!{%
683 \romannumeral0\BIC@AddXY#1!#2!!!%
684 }
685 \def\BigIntCalcSub#1!#2!{%
686 \romannumeral0\BIC@SubXY#1!#2!!!%
687 }
688 \def\BIC@AddXY#1#2!#3#4!#5!#6!{%
689 \ifx\\#2\\%
690 \ifx\\#3\\%
691 \BIC@AfterFiFi{%
692 \BIC@DoAdd0!#1#5!#60!%
693 }%
694 \else
695 \BIC@AfterFiFi{%
696 \BIC@DoAdd0!#1#5!#3#6!%
697 }%
698 \fi
699 \else
700 \ifx\\#4\\%
701 \ifx\\#3\\%
702 \BIC@AfterFiFiFi{%
703 \BIC@AddXY#2!{}!#1#5!#60!%
704 }%
705 \else
706 \BIC@AfterFiFiFi{%
707 \BIC@AddXY#2!{}!#1#5!#3#6!%
708 }%
709 \fi
710 \else
711 \BIC@AfterFiFi{%
712 \BIC@AddXY#2!#4!#1#5!#3#6!%
713 }%
714 \fi
715 \BIC@Fi
716 }
717 \def\BIC@DoAdd#1#2!#3#4!#5#6!{%
718 \ifx\\#4\\%
719 \BIC@AfterFi{%
720 & \expandafter\BIC@Space
721 & \the\numexpr#1+#3+#5\relax#2%
722 $ \expandafter\expandafter\expandafter\BIC@AddResult
723 $ \BIC@AddDigit#1#3#5#2%
724 }%
725 \else
726 \BIC@AfterFi{%
727 \expandafter\expandafter\expandafter\BIC@DoAdd
728 \BIC@AddDigit#1#3#5#2!#4!#6!%
729 }%
730 \BIC@Fi
731 }
732 $ \def\BIC@AddResult#1{%
733 $ \ifx#10%
734 $ \expandafter\BIC@Space
735 $ \else
736 $ \expandafter\BIC@Space\expandafter#1%
737 $ \fi
738 $ }%
739 \def\BIC@AddDigit#1#2#3{%
740 \romannumeral0%
741 & \expandafter\BIC@@AddDigit\the\numexpr#1+#2+#3!%
742 $ \expandafter\BIC@@AddDigit\number%
743 $ \csname
744 $ BIC@AddCarry%
745 $ \ifcase#1 %
746 $ #2%
747 $ \else
748 $ \ifcase#2 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi
749 $ \fi
750 $ \endcsname#3!%
751 }
752 \def\BIC@@AddDigit#1!{%
753 \ifnum#1<10 %
754 \BIC@AfterFi{ 0#1}%
755 \else
756 \BIC@AfterFi{ #1}%
757 \BIC@Fi
758 }
759 $ \expandafter\def\csname BIC@AddCarry0\endcsname#1{#1}%
760 $ \expandafter\def\csname BIC@AddCarry10\endcsname#1{1#1}%
761 $ \def\BIC@Temp#1#2{%
762 $ \expandafter\def\csname BIC@AddCarry#1\endcsname##1{%
763 $ \ifcase##1 #1\or
764 $ #2%
765 $? \else\BigIntCalcError:ThisCannotHappen%
766 $ \fi
767 $ }%
768 $ }%
769 $ \BIC@Temp 0{1\or2\or3\or4\or5\or6\or7\or8\or9}%
770 $ \BIC@Temp 1{2\or3\or4\or5\or6\or7\or8\or9\or10}%
771 $ \BIC@Temp 2{3\or4\or5\or6\or7\or8\or9\or10\or11}%
772 $ \BIC@Temp 3{4\or5\or6\or7\or8\or9\or10\or11\or12}%
773 $ \BIC@Temp 4{5\or6\or7\or8\or9\or10\or11\or12\or13}%
774 $ \BIC@Temp 5{6\or7\or8\or9\or10\or11\or12\or13\or14}%
775 $ \BIC@Temp 6{7\or8\or9\or10\or11\or12\or13\or14\or15}%
776 $ \BIC@Temp 7{8\or9\or10\or11\or12\or13\or14\or15\or16}%
777 $ \BIC@Temp 8{9\or10\or11\or12\or13\or14\or15\or16\or17}%
778 $ \BIC@Temp 9{10\or11\or12\or13\or14\or15\or16\or17\or18}%
779 \def\BIC@SubXY#1#2!#3#4!#5!#6!{%
780 \ifx\\#2\\%
781 \ifx\\#3\\%
782 \BIC@AfterFiFi{%
783 \BIC@DoSub0!#1#5!#60!%
784 }%
785 \else
786 \BIC@AfterFiFi{%
787 \BIC@DoSub0!#1#5!#3#6!%
788 }%
789 \fi
790 \else
791 \ifx\\#4\\%
792 \ifx\\#3\\%
793 \BIC@AfterFiFiFi{%
794 \BIC@SubXY#2!{}!#1#5!#60!%
795 }%
796 \else
797 \BIC@AfterFiFiFi{%
798 \BIC@SubXY#2!{}!#1#5!#3#6!%
799 }%
800 \fi
801 \else
802 \BIC@AfterFiFi{%
803 \BIC@SubXY#2!#4!#1#5!#3#6!%
804 }%
805 \fi
806 \BIC@Fi
807 }
808 \def\BIC@DoSub#1#2!#3#4!#5#6!{%
809 \ifx\\#4\\%
810 \BIC@AfterFi{%
811 \expandafter\expandafter\expandafter\BIC@SubResult
812 \BIC@SubDigit#1#3#5#2%
813 }%
814 \else
815 \BIC@AfterFi{%
816 \expandafter\expandafter\expandafter\BIC@DoSub
817 \BIC@SubDigit#1#3#5#2!#4!#6!%
818 }%
819 \BIC@Fi
820 }
821 \def\BIC@SubResult#1{%
822 \ifx#10%
823 \expandafter\BIC@SubResult
824 \else
825 \expandafter\BIC@Space\expandafter#1%
826 \fi
827 }
828 \def\BIC@SubDigit#1#2#3{%
829 \romannumeral0%
830 & \expandafter\BIC@@SubDigit\the\numexpr#2-#3-#1!%
831 $ \expandafter\BIC@@AddDigit\number
832 $ \csname
833 $ BIC@SubCarry%
834 $ \ifcase#1 %
835 $ #3%
836 $ \else
837 $ \ifcase#3 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi
838 $ \fi
839 $ \endcsname#2!%
840 }
841 & \def\BIC@@SubDigit#1!{%
842 & \ifnum#1<0 %
843 & \BIC@AfterFi{%
844 & \expandafter\BIC@Space
845 & \expandafter1\the\numexpr#1+10\relax
846 & }%
847 & \else
848 & \BIC@AfterFi{ 0#1}%
849 & \BIC@Fi
850 & }%
851 $ \expandafter\def\csname BIC@SubCarry0\endcsname#1{#1}%
852 $ \expandafter\def\csname BIC@SubCarry10\endcsname#1{1#1}%
853 $ \def\BIC@Temp#1#2{%
854 $ \expandafter\def\csname BIC@SubCarry#1\endcsname##1{%
855 $ \ifcase##1 #2%
856 $? \else\BigIntCalcError:ThisCannotHappen%
857 $ \fi
858 $ }%
859 $ }%
860 $ \BIC@Temp 1{19\or0\or1\or2\or3\or4\or5\or6\or7\or8}%
861 $ \BIC@Temp 2{18\or19\or0\or1\or2\or3\or4\or5\or6\or7}%
862 $ \BIC@Temp 3{17\or18\or19\or0\or1\or2\or3\or4\or5\or6}%
863 $ \BIC@Temp 4{16\or17\or18\or19\or0\or1\or2\or3\or4\or5}%
864 $ \BIC@Temp 5{15\or16\or17\or18\or19\or0\or1\or2\or3\or4}%
865 $ \BIC@Temp 6{14\or15\or16\or17\or18\or19\or0\or1\or2\or3}%
866 $ \BIC@Temp 7{13\or14\or15\or16\or17\or18\or19\or0\or1\or2}%
867 $ \BIC@Temp 8{12\or13\or14\or15\or16\or17\or18\or19\or0\or1}%
868 $ \BIC@Temp 9{11\or12\or13\or14\or15\or16\or17\or18\or19\or0}%
869 \def\bigintcalcShl#1{%
870 \romannumeral0%
871 \expandafter\expandafter\expandafter\BIC@Shl
872 \bigintcalcNum{#1}!%
873 }
874 \def\BIC@Shl#1#2!{%
875 \ifx#1-%
876 \BIC@AfterFi{%
877 \expandafter-\romannumeral0%
878 & \BIC@@Shl#2!!%
879 $ \BIC@AddXY#2!#2!!!%
880 }%
881 \else
882 \BIC@AfterFi{%
883 & \BIC@@Shl#1#2!!%
884 $ \BIC@AddXY#1#2!#1#2!!!%
885 }%
886 \BIC@Fi
887 }
888 \def\BigIntCalcShl#1!{%
889 \romannumeral0%
890 & \BIC@@Shl#1!!%
891 $ \BIC@AddXY#1!#1!!!%
892 }
893 & \def\BIC@@Shl#1#2!{%
894 & \ifx\\#2\\%
895 & \BIC@AfterFi{%
896 & \BIC@@@Shl0!#1%
897 & }%
898 & \else
899 & \BIC@AfterFi{%
900 & \BIC@@Shl#2!#1%
901 & }%
902 & \BIC@Fi
903 & }%
904 & \def\BIC@@@Shl#1#2!#3#4!{%
905 & \ifx\\#4\\%
906 & \BIC@AfterFi{%
907 & \expandafter\BIC@Space
908 & \the\numexpr#3*2+#1\relax#2%
909 & }%
910 & \else
911 & \BIC@AfterFi{%
912 & \expandafter\BIC@@@@Shl\the\numexpr#3*2+#1!#2!#4!%
913 & }%
914 & \BIC@Fi
915 & }%
916 & \def\BIC@@@@Shl#1!{%
917 & \ifnum#1<10 %
918 & \BIC@AfterFi{%
919 & \BIC@@@Shl0#1%
920 & }%
921 & \else
922 & \BIC@AfterFi{%
923 & \BIC@@@Shl#1%
924 & }%
925 & \BIC@Fi
926 & }%
927 \def\bigintcalcShr#1{%
928 \romannumeral0%
929 \expandafter\expandafter\expandafter\BIC@Shr
930 \bigintcalcNum{#1}!%
931 }
932 \def\BIC@Shr#1#2!{%
933 \ifx#1-%
934 \expandafter-\romannumeral0%
935 \BIC@AfterFi{%
936 \BIC@@Shr#2!%
937 }%
938 \else
939 \BIC@AfterFi{%
940 \BIC@@Shr#1#2!%
941 }%
942 \BIC@Fi
943 }
944 \def\BigIntCalcShr#1!{%
945 \romannumeral0%
946 \BIC@@Shr#1!%
947 }
948 \def\BIC@@Shr#1#2!{%
949 \ifcase#1 %
950 \BIC@AfterFi{ 0}%
951 \or
952 \ifx\\#2\\%
953 \BIC@AfterFiFi{ 0}%
954 \else
955 \BIC@AfterFiFi{%
956 \BIC@@@Shr#1#2!!%
957 }%
958 \fi
959 \else
960 \BIC@AfterFi{%
961 \BIC@@@Shr0#1#2!!%
962 }%
963 \BIC@Fi
964 }
965 \def\BIC@@@Shr#1#2#3!#4!{%
966 \ifx\\#3\\%
967 \ifodd#1#2 %
968 \BIC@AfterFiFi{%
969 & \expandafter\BIC@ShrResult\the\numexpr(#1#2-1)/2\relax
970 $ \expandafter\expandafter\expandafter\BIC@ShrResult
971 $ \csname BIC@ShrDigit#1#2\endcsname
972 #4!%
973 }%
974 \else
975 \BIC@AfterFiFi{%
976 & \expandafter\BIC@ShrResult\the\numexpr#1#2/2\relax
977 $ \expandafter\expandafter\expandafter\BIC@ShrResult
978 $ \csname BIC@ShrDigit#1#2\endcsname
979 #4!%
980 }%
981 \fi
982 \else
983 \ifodd#1#2 %
984 \BIC@AfterFiFi{%
985 & \expandafter\BIC@@@@Shr\the\numexpr(#1#2-1)/2\relax1%
986 $ \expandafter\expandafter\expandafter\BIC@@@@Shr
987 $ \csname BIC@ShrDigit#1#2\endcsname
988 #3!#4!%
989 }%
990 \else
991 \BIC@AfterFiFi{%
992 & \expandafter\BIC@@@@Shr\the\numexpr#1#2/2\relax0%
993 $ \expandafter\expandafter\expandafter\BIC@@@@Shr
994 $ \csname BIC@ShrDigit#1#2\endcsname
995 #3!#4!%
996 }%
997 \fi
998 \BIC@Fi
999 }
1000 & \def\BIC@ShrResult#1#2!{ #2#1}%
1001 $ \def\BIC@ShrResult#1#2#3!{ #3#1}%
1002 \def\BIC@@@@Shr#1#2#3!#4!{%
1003 \BIC@@@Shr#2#3!#4#1!%
1004 }
1005 $ \def\BIC@Temp#1#2#3#4{%
1006 $ \expandafter\def\csname BIC@ShrDigit#1#2\endcsname{#3#4}%
1007 $ }%
1008 $ \BIC@Temp 0000%
1009 $ \BIC@Temp 0101%
1010 $ \BIC@Temp 0210%
1011 $ \BIC@Temp 0311%
1012 $ \BIC@Temp 0420%
1013 $ \BIC@Temp 0521%
1014 $ \BIC@Temp 0630%
1015 $ \BIC@Temp 0731%
1016 $ \BIC@Temp 0840%
1017 $ \BIC@Temp 0941%
1018 $ \BIC@Temp 1050%
1019 $ \BIC@Temp 1151%
1020 $ \BIC@Temp 1260%
1021 $ \BIC@Temp 1361%
1022 $ \BIC@Temp 1470%
1023 $ \BIC@Temp 1571%
1024 $ \BIC@Temp 1680%
1025 $ \BIC@Temp 1781%
1026 $ \BIC@Temp 1890%
1027 $ \BIC@Temp 1991%
1028 \def\BIC@Tim#1!#2{%
1029 \romannumeral0%
1030 \ifcase#2 % 0
1031 \BIC@AfterFi{ 0}%
1032 \or % 1
1033 \BIC@AfterFi{ #1}%
1034 \or % 2
1035 \BIC@AfterFi{%
1036 \BIC@Shl#1!%
1037 }%
1038 \else % 3-9
1039 \BIC@AfterFi{%
1040 \BIC@@Tim#1!!#2%
1041 }%
1042 \BIC@Fi
1043 }
1044 \def\BIC@@Tim#1#2!{%
1045 \ifx\\#2\\%
1046 \BIC@AfterFi{%
1047 \BIC@ProcessTim0!#1%
1048 }%
1049 \else
1050 \BIC@AfterFi{%
1051 \BIC@@Tim#2!#1%
1052 }%
1053 \BIC@Fi
1054 }
1055 \def\BIC@ProcessTim#1#2!#3#4!#5{%
1056 \ifx\\#4\\%
1057 \BIC@AfterFi{%
1058 \expandafter\BIC@Space
1059 & \the\numexpr#3*#5+#1\relax
1060 $ \romannumeral0\BIC@TimDigit#3#5#1%
1061 #2%
1062 }%
1063 \else
1064 \BIC@AfterFi{%
1065 \expandafter\BIC@@ProcessTim
1066 & \the\numexpr#3*#5+#1%
1067 $ \romannumeral0\BIC@TimDigit#3#5#1%
1068 !#2!#4!#5%
1069 }%
1070 \BIC@Fi
1071 }
1072 \def\BIC@@ProcessTim#1#2!{%
1073 \ifx\\#2\\%
1074 \BIC@AfterFi{%
1075 \BIC@ProcessTim0#1%
1076 }%
1077 \else
1078 \BIC@AfterFi{%
1079 \BIC@ProcessTim#1#2%
1080 }%
1081 \BIC@Fi
1082 }
1083 $ \def\BIC@TimDigit#1#2#3{%
1084 $ \ifcase#1 % 0
1085 $ \BIC@AfterFi{ #3}%
1086 $ \or % 1
1087 $ \BIC@AfterFi{%
1088 $ \expandafter\BIC@Space
1089 $ \number\csname BIC@AddCarry#2\endcsname#3 %
1090 $ }%
1091 $ \else
1092 $ \ifcase#3 %
1093 $ \BIC@AfterFiFi{%
1094 $ \expandafter\BIC@Space
1095 $ \number\csname BIC@MulDigit#2\endcsname#1 %
1096 $ }%
1097 $ \else
1098 $ \BIC@AfterFiFi{%
1099 $ \expandafter\BIC@Space
1100 $ \romannumeral0%
1101 $ \expandafter\BIC@AddXY
1102 $ \number\csname BIC@MulDigit#2\endcsname#1!%
1103 $ #3!!!%
1104 $ }%
1105 $ \fi
1106 $ \BIC@Fi
1107 $ }%
1108 $ \def\BIC@Temp#1#2{%
1109 $ \expandafter\def\csname BIC@MulDigit#1\endcsname##1{%
1110 $ \ifcase##1 0%
1111 $ \or ##1%
1112 $ \or #2%
1113 $? \else\BigIntCalcError:ThisCannotHappen%
1114 $ \fi
1115 $ }%
1116 $ }%
1117 $ \BIC@Temp 3{6\or9\or12\or15\or18\or21\or24\or27}%
1118 $ \BIC@Temp 4{8\or12\or16\or20\or24\or28\or32\or36}%
1119 $ \BIC@Temp 5{10\or15\or20\or25\or30\or35\or40\or45}%
1120 $ \BIC@Temp 6{12\or18\or24\or30\or36\or42\or48\or54}%
1121 $ \BIC@Temp 7{14\or21\or28\or35\or42\or49\or56\or63}%
1122 $ \BIC@Temp 8{16\or24\or32\or40\or48\or56\or64\or72}%
1123 $ \BIC@Temp 9{18\or27\or36\or45\or54\or63\or72\or81}%
1124 \def\bigintcalcMul#1#2{%
1125 \romannumeral0%
1126 \expandafter\expandafter\expandafter\BIC@Mul
1127 \bigintcalcNum{#1}!{#2}%
1128 }
1129 \def\BIC@Mul#1!#2{%
1130 \expandafter\expandafter\expandafter\BIC@MulSwitch
1131 \bigintcalcNum{#2}!#1!%
1132 }
1133 \def\BIC@MulSwitch#1#2!#3#4!{%
1134 \ifcase\BIC@Sgn#1#2! % x = 0
1135 \BIC@AfterFi{ 0}%
1136 \or % x > 0
1137 \ifcase\BIC@Sgn#3#4! % y = 0
1138 \BIC@AfterFiFi{ 0}%
1139 \or % y > 0
1140 \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y
1141 \BIC@AfterFiFiFi{%
1142 \BIC@ProcessMul0!#1#2!#3#4!%
1143 }%
1144 \else % x <= y
1145 \BIC@AfterFiFiFi{%
1146 \BIC@ProcessMul0!#3#4!#1#2!%
1147 }%
1148 \fi
1149 \else % y < 0
1150 \expandafter-\romannumeral0%
1151 \ifnum\BIC@PosCmp#1#2!#4!=1 % x > -y
1152 \BIC@AfterFiFiFi{%
1153 \BIC@ProcessMul0!#1#2!#4!%
1154 }%
1155 \else % x <= -y
1156 \BIC@AfterFiFiFi{%
1157 \BIC@ProcessMul0!#4!#1#2!%
1158 }%
1159 \fi
1160 \fi
1161 \else % x < 0
1162 \ifcase\BIC@Sgn#3#4! % y = 0
1163 \BIC@AfterFiFi{ 0}%
1164 \or % y > 0
1165 \expandafter-\romannumeral0%
1166 \ifnum\BIC@PosCmp#2!#3#4!=1 % -x > y
1167 \BIC@AfterFiFiFi{%
1168 \BIC@ProcessMul0!#2!#3#4!%
1169 }%
1170 \else % -x <= y
1171 \BIC@AfterFiFiFi{%
1172 \BIC@ProcessMul0!#3#4!#2!%
1173 }%
1174 \fi
1175 \else % y < 0
1176 \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y
1177 \BIC@AfterFiFiFi{%
1178 \BIC@ProcessMul0!#2!#4!%
1179 }%
1180 \else % -x <= -y
1181 \BIC@AfterFiFiFi{%
1182 \BIC@ProcessMul0!#4!#2!%
1183 }%
1184 \fi
1185 \fi
1186 \BIC@Fi
1187 }
1188 \def\BigIntCalcMul#1!#2!{%
1189 \romannumeral0%
1190 \BIC@ProcessMul0!#1!#2!%
1191 }
1192 \def\BIC@ProcessMul#1!#2!#3#4!{%
1193 \ifx\\#4\\%
1194 \BIC@AfterFi{%
1195 \expandafter\expandafter\expandafter\BIC@Space
1196 \bigintcalcAdd{\BIC@Tim#2!#3}{#10}%
1197 }%
1198 \else
1199 \BIC@AfterFi{%
1200 \expandafter\expandafter\expandafter\BIC@ProcessMul
1201 \bigintcalcAdd{\BIC@Tim#2!#3}{#10}!#2!#4!%
1202 }%
1203 \BIC@Fi
1204 }
1205 \def\bigintcalcSqr#1{%
1206 \romannumeral0%
1207 \expandafter\expandafter\expandafter\BIC@Sqr
1208 \bigintcalcNum{#1}!%
1209 }
1210 \def\BIC@Sqr#1{%
1211 \ifx#1-%
1212 \expandafter\BIC@@Sqr
1213 \else
1214 \expandafter\BIC@@Sqr\expandafter#1%
1215 \fi
1216 }
1217 \def\BIC@@Sqr#1!{%
1218 \BIC@ProcessMul0!#1!#1!%
1219 }
1220 \def\bigintcalcFac#1{%
1221 \romannumeral0%
1222 \expandafter\expandafter\expandafter\BIC@Fac
1223 \bigintcalcNum{#1}!%
1224 }
1225 \def\BIC@Fac#1#2!{%
1226 \ifx#1-%
1227 \BIC@AfterFi{ 0\BigIntCalcError:FacNegative}%
1228 \else
1229 \ifnum\BIC@PosCmp#1#2!13!<0 %
1230 \ifcase#1#2 %
1231 \BIC@AfterFiFiFi{ 1}% 0!
1232 \or\BIC@AfterFiFiFi{ 1}% 1!
1233 \or\BIC@AfterFiFiFi{ 2}% 2!
1234 \or\BIC@AfterFiFiFi{ 6}% 3!
1235 \or\BIC@AfterFiFiFi{ 24}% 4!
1236 \or\BIC@AfterFiFiFi{ 120}% 5!
1237 \or\BIC@AfterFiFiFi{ 720}% 6!
1238 \or\BIC@AfterFiFiFi{ 5040}% 7!
1239 \or\BIC@AfterFiFiFi{ 40320}% 8!
1240 \or\BIC@AfterFiFiFi{ 362880}% 9!
1241 \or\BIC@AfterFiFiFi{ 3628800}% 10!
1242 \or\BIC@AfterFiFiFi{ 39916800}% 11!
1243 \or\BIC@AfterFiFiFi{ 479001600}% 12!
1244 ? \else\BigIntCalcError:ThisCannotHappen%
1245 \fi
1246 \else
1247 \BIC@AfterFiFi{%
1248 \BIC@ProcessFac#1#2!479001600!%
1249 }%
1250 \fi
1251 \BIC@Fi
1252 }
1253 \def\BIC@ProcessFac#1!#2!{%
1254 \ifnum\BIC@PosCmp#1!12!=0 %
1255 \BIC@AfterFi{ #2}%
1256 \else
1257 \BIC@AfterFi{%
1258 \expandafter\BIC@@ProcessFac
1259 \romannumeral0\BIC@ProcessMul0!#2!#1!%
1260 !#1!%
1261 }%
1262 \BIC@Fi
1263 }
1264 \def\BIC@@ProcessFac#1!#2!{%
1265 \expandafter\BIC@ProcessFac
1266 \romannumeral0\BIC@Dec#2!{}%
1267 !#1!%
1268 }
1269 \def\bigintcalcPow#1{%
1270 \romannumeral0%
1271 \expandafter\expandafter\expandafter\BIC@Pow
1272 \bigintcalcNum{#1}!%
1273 }
1274 \def\BIC@Pow#1!#2{%
1275 \expandafter\expandafter\expandafter\BIC@PowSwitch
1276 \bigintcalcNum{#2}!#1!%
1277 }
1278 \def\BIC@PowSwitch#1#2!#3#4!{%
1279 \ifcase\ifx\\#2\\%
1280 \ifx#100 % y = 0
1281 \else\ifx#111 % y = 1
1282 \else\ifx#122 % y = 2
1283 \else4 % y > 2
1284 \fi\fi\fi
1285 \else
1286 \ifx#1-3 % y < 0
1287 \else4 % y > 2
1288 \fi
1289 \fi
1290 \BIC@AfterFi{ 1}% y = 0
1291 \or % y = 1
1292 \BIC@AfterFi{ #3#4}%
1293 \or % y = 2
1294 \ifx#3-% x < 0
1295 \BIC@AfterFiFi{%
1296 \BIC@ProcessMul0!#4!#4!%
1297 }%
1298 \else % x >= 0
1299 \BIC@AfterFiFi{%
1300 \BIC@ProcessMul0!#3#4!#3#4!%
1301 }%
1302 \fi
1303 \or % y < 0
1304 \ifcase\ifx\\#4\\%
1305 \ifx#300 % x = 0
1306 \else\ifx#311 % x = 1
1307 \else3 % x > 1
1308 \fi\fi
1309 \else
1310 \ifcase\BIC@MinusOne#3#4! %
1311 3 % |x| > 1
1312 \or
1313 2 % x = -1
1314 ? \else\BigIntCalcError:ThisCannotHappen%
1315 \fi
1316 \fi
1317 \BIC@AfterFiFi{ 0\BigIntCalcError:DivisionByZero}% x = 0
1318 \or % x = 1
1319 \BIC@AfterFiFi{ 1}% x = 1
1320 \or % x = -1
1321 \ifcase\BIC@ModTwo#2! % even(y)
1322 \BIC@AfterFiFiFi{ 1}%
1323 \or % odd(y)
1324 \BIC@AfterFiFiFi{ -1}%
1325 ? \else\BigIntCalcError:ThisCannotHappen%
1326 \fi
1327 \or % |x| > 1
1328 \BIC@AfterFiFi{ 0}%
1329 ? \else\BigIntCalcError:ThisCannotHappen%
1330 \fi
1331 \or % y > 2
1332 \ifcase\ifx\\#4\\%
1333 \ifx#300 % x = 0
1334 \else\ifx#311 % x = 1
1335 \else4 % x > 1
1336 \fi\fi
1337 \else
1338 \ifx#3-%
1339 \ifcase\BIC@MinusOne#3#4! %
1340 3 % x < -1
1341 \else
1342 2 % x = -1
1343 \fi
1344 \else
1345 4 % x > 1
1346 \fi
1347 \fi
1348 \BIC@AfterFiFi{ 0}% x = 0
1349 \or % x = 1
1350 \BIC@AfterFiFi{ 1}% x = 1
1351 \or % x = -1
1352 \ifcase\BIC@ModTwo#1#2! % even(y)
1353 \BIC@AfterFiFiFi{ 1}%
1354 \or % odd(y)
1355 \BIC@AfterFiFiFi{ -1}%
1356 ? \else\BigIntCalcError:ThisCannotHappen%
1357 \fi
1358 \or % x < -1
1359 \ifcase\BIC@ModTwo#1#2! % even(y)
1360 \BIC@AfterFiFiFi{%
1361 \BIC@PowRec#4!#1#2!1!%
1362 }%
1363 \or % odd(y)
1364 \expandafter-\romannumeral0%
1365 \BIC@AfterFiFiFi{%
1366 \BIC@PowRec#4!#1#2!1!%
1367 }%
1368 ? \else\BigIntCalcError:ThisCannotHappen%
1369 \fi
1370 \or % x > 1
1371 \BIC@AfterFiFi{%
1372 \BIC@PowRec#3#4!#1#2!1!%
1373 }%
1374 ? \else\BigIntCalcError:ThisCannotHappen%
1375 \fi
1376 ? \else\BigIntCalcError:ThisCannotHappen%
1377 \BIC@Fi
1378 }
1379 \def\BIC@ModTwo#1#2!{%
1380 \ifx\\#2\\%
1381 \ifodd#1 %
1382 \BIC@AfterFiFi1%
1383 \else
1384 \BIC@AfterFiFi0%
1385 \fi
1386 \else
1387 \BIC@AfterFi{%
1388 \BIC@ModTwo#2!%
1389 }%
1390 \BIC@Fi
1391 }
1392 \def\BIC@MinusOne#1#2!{%
1393 \ifx#1-%
1394 \BIC@@MinusOne#2!%
1395 \else
1396 0%
1397 \fi
1398 }
1399 \def\BIC@@MinusOne#1#2!{%
1400 \ifx#11%
1401 \ifx\\#2\\%
1402 1%
1403 \else
1404 0%
1405 \fi
1406 \else
1407 0%
1408 \fi
1409 }
1410 \def\BIC@PowRec#1!#2#3!#4!{%
1411 \ifcase\ifx#21\ifx\\#3\\0 \else1 \fi\else1 \fi % y = 1
1412 \ifnum\BIC@PosCmp#1!#4!=1 % x > r
1413 \BIC@AfterFiFi{%
1414 \BIC@ProcessMul0!#1!#4!%
1415 }%
1416 \else
1417 \BIC@AfterFiFi{%
1418 \BIC@ProcessMul0!#4!#1!%
1419 }%
1420 \fi
1421 \or
1422 \ifcase\BIC@ModTwo#2#3! % even(y)
1423 \BIC@AfterFiFi{%
1424 \expandafter\BIC@@PowRec\romannumeral0%
1425 \BIC@@Shr#2#3!%
1426 !#1!#4!%
1427 }%
1428 \or % odd(y)
1429 \ifnum\BIC@PosCmp#1!#4!=1 % x > r
1430 \BIC@AfterFiFiFi{%
1431 \expandafter\BIC@@@PowRec\romannumeral0%
1432 \BIC@ProcessMul0!#1!#4!%
1433 !#1!#2#3!%
1434 }%
1435 \else
1436 \BIC@AfterFiFiFi{%
1437 \expandafter\BIC@@@PowRec\romannumeral0%
1438 \BIC@ProcessMul0!#1!#4!%
1439 !#1!#2#3!%
1440 }%
1441 \fi
1442 ? \else\BigIntCalcError:ThisCannotHappen%
1443 \fi
1444 ? \else\BigIntCalcError:ThisCannotHappen%
1445 \BIC@Fi
1446 }
1447 \def\BIC@@PowRec#1!#2!#3!{%
1448 \expandafter\BIC@PowRec\romannumeral0%
1449 \BIC@ProcessMul0!#2!#2!%
1450 !#1!#3!%
1451 }
1452 \def\BIC@@@PowRec#1!#2!#3!{%
1453 \expandafter\BIC@@PowRec\romannumeral0%
1454 \BIC@@Shr#3!%
1455 !#2!#1!%
1456 }
1457 \def\bigintcalcDiv#1{%
1458 \romannumeral0%
1459 \expandafter\expandafter\expandafter\BIC@Div
1460 \bigintcalcNum{#1}!%
1461 }
1462 \def\BIC@Div#1!#2{%
1463 \expandafter\expandafter\expandafter\BIC@DivSwitchSign
1464 \bigintcalcNum{#2}!#1!%
1465 }
1466 \def\BigIntCalcDiv#1!#2!{%
1467 \romannumeral0%
1468 \BIC@DivSwitchSign#2!#1!%
1469 }
1470 \def\BIC@DivSwitchSign#1#2!#3#4!{%
1471 \ifcase\BIC@Sgn#1#2! % y = 0
1472 \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}%
1473 \or % y > 0
1474 \ifcase\BIC@Sgn#3#4! % x = 0
1475 \BIC@AfterFiFi{ 0}%
1476 \or % x > 0
1477 \BIC@AfterFiFi{%
1478 \BIC@DivSwitch{}#3#4!#1#2!%
1479 }%
1480 \else % x < 0
1481 \BIC@AfterFiFi{%
1482 \BIC@DivSwitch-#4!#1#2!%
1483 }%
1484 \fi
1485 \else % y < 0
1486 \ifcase\BIC@Sgn#3#4! % x = 0
1487 \BIC@AfterFiFi{ 0}%
1488 \or % x > 0
1489 \BIC@AfterFiFi{%
1490 \BIC@DivSwitch-#3#4!#2!%
1491 }%
1492 \else % x < 0
1493 \BIC@AfterFiFi{%
1494 \BIC@DivSwitch{}#4!#2!%
1495 }%
1496 \fi
1497 \BIC@Fi
1498 }
1499 \def\BIC@DivSwitch#1#2!#3#4!{%
1500 \ifcase\BIC@PosCmp#3#4!#2!% y = x
1501 \BIC@AfterFi{ #11}%
1502 \or % y > x
1503 \BIC@AfterFi{ 0}%
1504 \else % y < x
1505 \ifx\\#1\\%
1506 \else
1507 \expandafter-\romannumeral0%
1508 \fi
1509 \ifcase\ifx\\#4\\%
1510 \ifx#310 % y = 1
1511 \else\ifx#321 % y = 2
1512 \else\ifx#342 % y = 4
1513 \else3 % y > 2
1514 \fi\fi\fi
1515 \else
1516 3 % y > 2
1517 \fi
1518 \BIC@AfterFiFi{ #2}% y = 1
1519 \or % y = 2
1520 \BIC@AfterFiFi{%
1521 \BIC@@Shr#2!%
1522 }%
1523 \or % y = 4
1524 \BIC@AfterFiFi{%
1525 \expandafter\BIC@@Shr\romannumeral0%
1526 \BIC@@Shr#2!!%
1527 }%
1528 \or % y > 2
1529 \BIC@AfterFiFi{%
1530 \BIC@DivStartX#2!#3#4!!!%
1531 }%
1532 ? \else\BigIntCalcError:ThisCannotHappen%
1533 \fi
1534 \BIC@Fi
1535 }
1536 \def\BIC@DivStartX#1#2!#3#4!#5!#6!{%
1537 \ifx\\#4\\%
1538 \BIC@AfterFi{%
1539 \BIC@DivStartYii#6#3#4!{#5#1}#2=!%
1540 }%
1541 \else
1542 \BIC@AfterFi{%
1543 \BIC@DivStartX#2!#4!#5#1!#6#3!%
1544 }%
1545 \BIC@Fi
1546 }
1547 \def\BIC@DivStartYii#1!{%
1548 \expandafter\BIC@DivStartYiv\romannumeral0%
1549 \BIC@Shl#1!%
1550 !#1!%
1551 }
1552 \def\BIC@DivStartYiv#1!{%
1553 \expandafter\BIC@DivStartYvi\romannumeral0%
1554 \BIC@Shl#1!%
1555 !#1!%
1556 }
1557 \def\BIC@DivStartYvi#1!#2!{%
1558 \expandafter\BIC@DivStartYviii\romannumeral0%
1559 \BIC@AddXY#1!#2!!!%
1560 !#1!#2!%
1561 }
1562 \def\BIC@DivStartYviii#1!#2!{%
1563 \expandafter\BIC@DivStart\romannumeral0%
1564 \BIC@Shl#2!%
1565 !#1!#2!%
1566 }
1567 \def\BIC@DivStart#1!#2!#3!#4!#5!#6!{%
1568 \BIC@ProcessDiv#6!!#5!#4!#3!#2!#1!=%
1569 }
1570 \def\BIC@ProcessDiv#1#2#3!#4!#5!{%
1571 \ifcase\BIC@PosCmp#5!#1!% y = #1
1572 \ifx#2=%
1573 \BIC@AfterFiFi{\BIC@DivCleanup{#41}}%
1574 \else
1575 \BIC@AfterFiFi{%
1576 \BIC@ProcessDiv#2#3!#41!#5!%
1577 }%
1578 \fi
1579 \or % y > #1
1580 \ifx#2=%
1581 \BIC@AfterFiFi{\BIC@DivCleanup{#40}}%
1582 \else
1583 \ifx\\#4\\%
1584 \BIC@AfterFiFiFi{%
1585 \BIC@ProcessDiv{#1#2}#3!!#5!%
1586 }%
1587 \else
1588 \BIC@AfterFiFiFi{%
1589 \BIC@ProcessDiv{#1#2}#3!#40!#5!%
1590 }%
1591 \fi
1592 \fi
1593 \else % y < #1
1594 \BIC@AfterFi{%
1595 \BIC@@ProcessDiv{#1}#2#3!#4!#5!%
1596 }%
1597 \BIC@Fi
1598 }
1599 \def\BIC@DivCleanup#1#2={ #1}%
1600 \def\BIC@@ProcessDiv#1#2#3!#4!#5!#6!#7!{%
1601 \ifcase\BIC@PosCmp#7!#1!% 4y = #1
1602 \ifx#2=%
1603 \BIC@AfterFiFi{\BIC@DivCleanup{#44}}%
1604 \else
1605 \BIC@AfterFiFi{%
1606 \BIC@ProcessDiv#2#3!#44!#5!#6!#7!%
1607 }%
1608 \fi
1609 \or % 4y > #1
1610 \ifcase\BIC@PosCmp#6!#1!% 2y = #1
1611 \ifx#2=%
1612 \BIC@AfterFiFiFi{\BIC@DivCleanup{#42}}%
1613 \else
1614 \BIC@AfterFiFiFi{%
1615 \BIC@ProcessDiv#2#3!#42!#5!#6!#7!%
1616 }%
1617 \fi
1618 \or % 2y > #1
1619 \ifx#2=%
1620 \BIC@AfterFiFiFi{\BIC@DivCleanup{#41}}%
1621 \else
1622 \BIC@AfterFiFiFi{%
1623 \BIC@DivSub#1!#5!#2#3!#41!#5!#6!#7!%
1624 }%
1625 \fi
1626 \else % 2y < #1
1627 \BIC@AfterFiFi{%
1628 \expandafter\BIC@ProcessDivII\romannumeral0%
1629 \BIC@SubXY#1!#6!!!%
1630 !#2#3!#4!#5!23%
1631 #6!#7!%
1632 }%
1633 \fi
1634 \else % 4y < #1
1635 \BIC@AfterFi{%
1636 \BIC@@@ProcessDiv{#1}#2#3!#4!#5!#6!#7!%
1637 }%
1638 \BIC@Fi
1639 }
1640 \def\BIC@DivSub#1!#2!#3{%
1641 \expandafter\BIC@ProcessDiv\expandafter{%
1642 \romannumeral0%
1643 \BIC@SubXY#1!#2!!!%
1644 #3%
1645 }%
1646 }
1647 \def\BIC@ProcessDivII#1!#2#3!#4!#5!#6#7{%
1648 \ifcase\BIC@PosCmp#5!#1!% y = #1
1649 \ifx#2=%
1650 \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}%
1651 \else
1652 \BIC@AfterFiFi{%
1653 \BIC@ProcessDiv#2#3!#4#7!#5!%
1654 }%
1655 \fi
1656 \or % y > #1
1657 \ifx#2=%
1658 \BIC@AfterFiFi{\BIC@DivCleanup{#4#6}}%
1659 \else
1660 \BIC@AfterFiFi{%
1661 \BIC@ProcessDiv{#1#2}#3!#4#6!#5!%
1662 }%
1663 \fi
1664 \else % y < #1
1665 \ifx#2=%
1666 \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}%
1667 \else
1668 \BIC@AfterFiFi{%
1669 \BIC@DivSub#1!#5!#2#3!#4#7!#5!%
1670 }%
1671 \fi
1672 \BIC@Fi
1673 }
1674 \def\BIC@@@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9!{%
1675 \ifcase\BIC@PosCmp#8!#1!% 6y = #1
1676 \ifx#2=%
1677 \BIC@AfterFiFi{\BIC@DivCleanup{#46}}%
1678 \else
1679 \BIC@AfterFiFi{%
1680 \BIC@ProcessDiv#2#3!#46!#5!#6!#7!#8!#9!%
1681 }%
1682 \fi
1683 \or % 6y > #1
1684 \BIC@AfterFi{%
1685 \expandafter\BIC@ProcessDivII\romannumeral0%
1686 \BIC@SubXY#1!#7!!!%
1687 !#2#3!#4!#5!45%
1688 #6!#7!#8!#9!%
1689 }%
1690 \else % 6y < #1
1691 \ifcase\BIC@PosCmp#9!#1!% 8y = #1
1692 \ifx#2=%
1693 \BIC@AfterFiFiFi{\BIC@DivCleanup{#48}}%
1694 \else
1695 \BIC@AfterFiFiFi{%
1696 \BIC@ProcessDiv#2#3!#48!#5!#6!#7!#8!#9!%
1697 }%
1698 \fi
1699 \or % 8y > #1
1700 \BIC@AfterFiFi{%
1701 \expandafter\BIC@ProcessDivII\romannumeral0%
1702 \BIC@SubXY#1!#8!!!%
1703 !#2#3!#4!#5!67%
1704 #6!#7!#8!#9!%
1705 }%
1706 \else % 8y < #1
1707 \BIC@AfterFiFi{%
1708 \expandafter\BIC@ProcessDivII\romannumeral0%
1709 \BIC@SubXY#1!#9!!!%
1710 !#2#3!#4!#5!89%
1711 #6!#7!#8!#9!%
1712 }%
1713 \fi
1714 \BIC@Fi
1715 }
1716 \def\bigintcalcMod#1{%
1717 \romannumeral0%
1718 \expandafter\expandafter\expandafter\BIC@Mod
1719 \bigintcalcNum{#1}!%
1720 }
1721 \def\BIC@Mod#1!#2{%
1722 \expandafter\expandafter\expandafter\BIC@ModSwitchSign
1723 \bigintcalcNum{#2}!#1!%
1724 }
1725 \def\BigIntCalcMod#1!#2!{%
1726 \romannumeral0%
1727 \BIC@ModSwitchSign#2!#1!%
1728 }
1729 \def\BIC@ModSwitchSign#1#2!#3#4!{%
1730 \ifcase\ifx\\#2\\%
1731 \ifx#100 % y = 0
1732 \else1 % y > 0
1733 \fi
1734 \else
1735 \ifx#1-2 % y < 0
1736 \else1 % y > 0
1737 \fi
1738 \fi
1739 \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}%
1740 \or % y > 0
1741 \ifcase\ifx\\#4\\\ifx#300 \else1 \fi\else1 \fi % x = 0
1742 \BIC@AfterFiFi{ 0}%
1743 \else
1744 \BIC@AfterFiFi{%
1745 \BIC@ModSwitch{}#3#4!#1#2!%
1746 }%
1747 \fi
1748 \else % y < 0
1749 \ifcase\ifx\\#4\\%
1750 \ifx#300 % x = 0
1751 \else1 % x > 0
1752 \fi
1753 \else
1754 \ifx#3-2 % x < 0
1755 \else1 % x > 0
1756 \fi
1757 \fi
1758 \BIC@AfterFiFi{ 0}%
1759 \or % x > 0
1760 \BIC@AfterFiFi{%
1761 \BIC@ModSwitch--#3#4!#2!%
1762 }%
1763 \else % x < 0
1764 \BIC@AfterFiFi{%
1765 \BIC@ModSwitch-#4!#2!%
1766 }%
1767 \fi
1768 \BIC@Fi
1769 }
1770 \def\BIC@ModSwitch#1#2#3!#4#5!{%
1771 \ifcase\ifx\\#5\\%
1772 \ifx#410 % y = 1
1773 \else\ifx#421 % y = 2
1774 \else2 % y > 2
1775 \fi\fi
1776 \else2 % y > 2
1777 \fi
1778 \BIC@AfterFi{ 0}% y = 1
1779 \or % y = 2
1780 \ifcase\BIC@ModTwo#2#3! % even(x)
1781 \BIC@AfterFiFi{ 0}%
1782 \or % odd(x)
1783 \BIC@AfterFiFi{ #11}%
1784 ? \else\BigIntCalcError:ThisCannotHappen%
1785 \fi
1786 \or % y > 2
1787 \ifx\\#1\\%
1788 \else
1789 \expandafter\BIC@Space\romannumeral0%
1790 \expandafter\BIC@ModMinus\romannumeral0%
1791 \fi
1792 \ifx#2-% x < 0
1793 \BIC@AfterFiFi{%
1794 \expandafter\expandafter\expandafter\BIC@ModX
1795 \bigintcalcSub{#2#3}{%
1796 \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}%
1797 }!#4#5!%
1798 }%
1799 \else % x > 0
1800 \BIC@AfterFiFi{%
1801 \expandafter\expandafter\expandafter\BIC@Space
1802 \bigintcalcSub{#2#3}{%
1803 \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}%
1804 }%
1805 }%
1806 \fi
1807 ? \else\BigIntCalcError:ThisCannotHappen%
1808 \BIC@Fi
1809 }
1810 \def\BIC@ModMinus#1{%
1811 \ifx#10%
1812 \BIC@AfterFi{ 0}%
1813 \else
1814 \BIC@AfterFi{ -#1}%
1815 \BIC@Fi
1816 }
1817 \def\BIC@ModX#1#2!#3!{%
1818 \ifx#1-% z < 0
1819 \BIC@AfterFi{%
1820 \expandafter\BIC@Space\romannumeral0%
1821 \BIC@SubXY#3!#2!!!%
1822 }%
1823 \else % z >= 0
1824 \BIC@AfterFi{ #1#2}%
1825 \BIC@Fi
1826 }
1827 \BIC@AtEnd%
1828 %% \section{Installation}
1829 \endinput
1830 %%
1831 %% End of file `bigintcalc.sty'.