# Direc­tory macros/latex/contrib/longdivision

Package: longdivision.sty version 1.0
Author: Hood Chatham
Email: hood@mit.edu
Date: 2017-02-05
Files:
longdivision.sty
longdivision_example.tex
longdivision_example.pdf

Does long division. The dividend must be a positive decimal number and the divisor must be a positive integer. Correctly handles repeating decimals, putting a bar over the repeated part of the decimal. Handles dividends up to 20 digits long gracefully (though the typeset result will take up about a page) and dividends between 20 and 60 digits long slightly less gracefully.

Defines macros \longdivision and \intlongdivision. Each takes two arguments, a dividend and divisor. \longdivision keeps dividing until the remainder is zero, or it encounters a repeated remainder. \longdivision stops when the dividend stops (though the dividend doesn't have to be an integer).

\longdivision also has an optional argument "max_extra_digits". If max_extra_digits is 0, the behavior is like \intlongdivision, whereas if max_extra_digits is greater than 60, the behavior is the same as \longdivision without the optional argument. In general, \longdivision won't add more than "max_extra_digits"  It might be prudent to use this optional argument if you are computing, say, 1/97 which has a 96 digit period (\longdivision will stop anyways to avoid overfull boxes, but the result might not be ideal).

\intlongdivision behaves similarly to the \longdiv command defined in longdiv.tex, though I think \intlongdivision looks better, and it can handle much larger dividends and divisors (the dividend is only constrained by the size of the page, and the divisor can be up to 8 digits long).

Please email me if you discover any bugs or have any feature requests. 

Down­load the con­tents of this pack­age in one zip archive (29.7k).

## long­di­vi­sion – Long di­vi­sion arith­metic prob­lems

This pack­age solves long di­vi­sion prob­lems and type­sets the so­lu­tions. The div­i­dend must be a pos­i­tive dec­i­mal num­ber and the di­vi­sor must be a pos­i­tive in­te­ger. Re­peat­ing dec­i­mals is han­dled cor­rectly, putting a bar over the re­peated part of the dec­i­mal. Div­i­dends up to 20 dig­its long are han­dled grace­fully (though the type­set re­sult will take up about a page), and div­i­dends be­tween 20 and 60 dig­its long slightly less grace­fully.

The pack­age de­fines two macros, \long­di­vi­sion and \int­long­di­vi­sion. Each takes two ar­gu­ments, a div­i­dend and a di­vi­sor. \long­di­vi­sion keeps di­vid­ing un­til the re­main­der is zero, or it en­coun­ters a re­peated re­main­der. \int­long­di­vi­sion stops when the div­i­dend stops (though the div­i­dend doesn't have to be an in­te­ger).

This pack­age de­pends on the xparse pack­age from the l3­pack­ages bun­dle.

 Pack­age long­di­vi­sion Ver­sion 1.0 2017-02-05 Li­censes The LaTeX Project Public Li­cense Main­tainer Hood Chatham Con­tained in TeX Live as long­di­vi­sionMiKTeX as long­di­vi­sion Topics MathsArith­metic See also longdiv