Skip to content

Lay out integer long division with \longdiv #302

Open

Description

@Happypig375

Implement the generic \longdiv{numerator}{denominator} command as an integer long-division layout, including quotient, intermediate subtraction rows, and final remainder.

Scope and semantics:

  • Follow the CTAN longdiv two-argument order: numerator first, denominator second.
  • Parse integer operands deterministically and reject zero denominators, malformed numbers, and unsupported ranges with source-positioned errors.
  • Use a semantic atom/display representation for the multi-row work; do not bake the result into a string, image, or unrelated array syntax.

Acceptance criteria:

  • Representative exact, non-exact, zero-quotient, multi-digit, and remainder cases have structural and golden rendering tests.
  • The divisor bracket, quotient, aligned work rows, rules, and remainder measure correctly in all line styles and under scaling.
  • Serialization preserves the canonical two-argument command and round-trips.
  • Invalid/missing arguments and division by zero produce deterministic, source-indexed diagnostics.
  • Define and test a safe numeric-size limit so hostile input cannot trigger unbounded allocation/work.

Reference syntax and behavior: https://ctan.org/pkg/longdiv

Parent backlog: #81.

Activity

  1. added
    Type/Enhancement
    Area/Parsing
    Area/Rendering
    on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area/ParsingArea/RenderingType/Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions