# jbezoz/bigint architecture

> Architecture diagram of the GitHub repository jbezoz/bigint, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jbezoz/bigint
- Repository: https://github.com/jbezoz/bigint

## Overview

#### Purpose
`BigInt` implements arithmetic for signed integers larger than native 64-bit types. The repository is a compact C++ implementation centered on custom arbitrary-precision integer representation and operations.

#### Entry Point
- `BigInt.cpp` is the sole implementation and likely contains the executable-facing logic, `BigInt` type definition, and arithmetic operation dispatch.
- `README.md` defines the intended capability: large signed integer arithmetic beyond 64-bit representation.

#### Core Big Integer Representation
- `BigInt.cpp` is the architectural boundary between native C++ integer facilities and arbitrary-precision values.
- The implementation must represent magnitude in a multi-digit or multi-word form plus separate sign handling, allowing values whose size is not constrained by machine integer width.

#### Signed Arithmetic Layer
- `BigInt.cpp` owns signed-operation semantics: normalization, sign propagation, and choosing magnitude addition versus subtraction.
- Addition and subtraction require comparison of magnitudes when operand signs differ.
- Multiplication combines operand magnitudes and derives the result sign from the inputs.

#### Carry, Borrow, and Digit Processing
- `BigInt.cpp` contains the low-level arithmetic stage that processes stored digits/words from least-significant to most-significant positions.
- Carry propagation, borrow handling, and result normalization are critical correctness boundaries because they prevent intermediate native-width operations from leaking into the public arbitrary-precision behavior.

#### Input/Output and Native Boundaries
- `BigInt.cpp` likely provides conversion or parsing/output behavior around the custom number representation.
- These boundaries should avoid converting complete large values back into 64-bit native types; native integers should only be used for per-digit calculations and indexing.

#### Runtime and Dependencies
- The project is a standalone C++ program/source unit with no indicated external services, databases, network infrastructure, package runtime, or third-party big-number library.
- Primary runtime dependency is the C++ standard library and compiler toolchain.

#### Repository Scope
- `BigInt.cpp` is the sole architecture-defining source path and should be treated as the canonical location for representation, arithmetic algorithms, and any command-line/demo behavior.
- `README.md` is the only documented contract for supported behavior.

Main entry points: [`BigInt.cpp`](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp) (Signed Arithmetic), [`README.md`](https://github.com/jbezoz/bigint/blob/main/README.md) (README)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bigint["Big Integer Core"]
  node_bigint_cpp["BigInt.cpp<br/>implementation unit<br/>[BigInt.cpp]"]
  node_public_ops["BigInt Operations<br/>operation dispatch<br/>[BigInt.cpp]"]
  node_representation["Signed Magnitude<br/>number representation<br/>[BigInt.cpp]"]
  node_normalization["Normalization<br/>invariant layer<br/>[BigInt.cpp]"]
  node_signed_arithmetic["Signed Arithmetic<br/>semantic layer<br/>[BigInt.cpp]"]
  node_magnitude_compare["Magnitude Comparison<br/>comparison algorithm<br/>[BigInt.cpp]"]
  node_magnitude_add["Magnitude Addition<br/>arithmetic algorithm<br/>[BigInt.cpp]"]
  node_magnitude_subtract["Magnitude Subtraction<br/>arithmetic algorithm<br/>[BigInt.cpp]"]
  node_magnitude_multiply["Magnitude Multiplication<br/>arithmetic algorithm<br/>[BigInt.cpp]"]
  node_digit_processing["Digit Processing<br/>low-level arithmetic<br/>[BigInt.cpp]"]
  node_native_boundary["Native Integer Boundary<br/>conversion boundary<br/>[BigInt.cpp]"]
  node_io_conversion["Parsing and Output<br/>I/O boundary<br/>[BigInt.cpp]"]
end

node_readme["README<br/>capability contract<br/>[README.md]"]
node_cpp_toolchain["C++ Toolchain<br/>runtime dependency"]

node_readme -.->|"defines capability"| node_bigint_cpp
node_cpp_toolchain -->|"builds and runs"| node_bigint_cpp
node_bigint_cpp -->|"contains"| node_public_ops
node_bigint_cpp -->|"defines"| node_representation
node_public_ops -->|"dispatches arithmetic"| node_signed_arithmetic
node_public_ops -->|"provides conversion"| node_io_conversion
node_signed_arithmetic -->|"compares differing signs"| node_magnitude_compare
node_signed_arithmetic -->|"selects"| node_magnitude_add
node_signed_arithmetic -->|"selects"| node_magnitude_subtract
node_signed_arithmetic -->|"signs result"| node_magnitude_multiply
node_representation -->|"supplies digits"| node_magnitude_compare
node_representation -->|"stores digits"| node_digit_processing
node_magnitude_add -->|"uses carry propagation"| node_digit_processing
node_magnitude_subtract -->|"uses borrow handling"| node_digit_processing
node_magnitude_multiply -->|"uses word operations"| node_digit_processing
node_digit_processing -->|"produces canonical digits"| node_normalization
node_signed_arithmetic -->|"canonicalizes result"| node_normalization
node_normalization -->|"updates value"| node_representation
node_io_conversion -->|"reads and emits magnitude"| node_representation
node_native_boundary -->|"bounds native arithmetic"| node_digit_processing
node_native_boundary -->|"limits conversion width"| node_io_conversion

click node_readme "https://github.com/jbezoz/bigint/blob/main/README.md"
click node_bigint_cpp "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_public_ops "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_representation "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_normalization "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_signed_arithmetic "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_magnitude_compare "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_magnitude_add "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_magnitude_subtract "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_magnitude_multiply "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_digit_processing "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_native_boundary "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"
click node_io_conversion "https://github.com/jbezoz/bigint/blob/main/BigInt.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bigint_cpp,node_public_ops,node_representation,node_normalization,node_signed_arithmetic,node_magnitude_compare,node_magnitude_add,node_magnitude_subtract,node_magnitude_multiply,node_digit_processing,node_native_boundary,node_io_conversion toneBlue
class node_readme,node_cpp_toolchain toneNeutral
```

## Components

### Big Integer Core

Custom arbitrary-precision integer implementation.

- [BigInt.cpp](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): implementation unit · Canonical source boundary for the BigInt type and executable-facing behavior. · `BigInt.cpp`
- [BigInt Operations](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): operation dispatch · Exposes signed arithmetic and conversion behavior. · `BigInt.cpp`
- [Signed Magnitude](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): number representation · Stores a separate sign and multi-digit or multi-word magnitude. · `BigInt.cpp`
- [Normalization](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): invariant layer · Canonicalizes digits and sign after operations. · `BigInt.cpp`
- [Signed Arithmetic](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): semantic layer · Selects magnitude addition or subtraction and propagates signs. · `BigInt.cpp`
- [Magnitude Comparison](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): comparison algorithm · Determines ordering when operand signs differ. · `BigInt.cpp`
- [Magnitude Addition](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): arithmetic algorithm · Adds stored magnitude digits. · `BigInt.cpp`
- [Magnitude Subtraction](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): arithmetic algorithm · Subtracts ordered magnitude digits. · `BigInt.cpp`
- [Magnitude Multiplication](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): arithmetic algorithm · Multiplies operand magnitudes before result-sign derivation. · `BigInt.cpp`
- [Digit Processing](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): low-level arithmetic · Processes digits from least to most significant position. · `BigInt.cpp`
- [Native Integer Boundary](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): conversion boundary · Uses native integers only for per-digit calculations and indexing. · `BigInt.cpp`
- [Parsing and Output](https://github.com/jbezoz/bigint/blob/main/BigInt.cpp): I/O boundary · Converts external text without reducing whole values to 64-bit integers. · `BigInt.cpp`

### Other components

- [README](https://github.com/jbezoz/bigint/blob/main/README.md): capability contract · Documents signed arithmetic beyond 64-bit values. · `README.md`
- **C++ Toolchain**: runtime dependency · Compiles and runs the standalone source unit.

## Connections

- README → BigInt.cpp: defines capability
- C++ Toolchain → BigInt.cpp: builds and runs
- BigInt.cpp → BigInt Operations: contains
- BigInt.cpp → Signed Magnitude: defines
- BigInt Operations → Signed Arithmetic: dispatches arithmetic
- BigInt Operations → Parsing and Output: provides conversion
- Signed Arithmetic → Magnitude Comparison: compares differing signs
- Signed Arithmetic → Magnitude Addition: selects
- Signed Arithmetic → Magnitude Subtraction: selects
- Signed Arithmetic → Magnitude Multiplication: signs result
- Signed Magnitude → Magnitude Comparison: supplies digits
- Signed Magnitude → Digit Processing: stores digits
- Magnitude Addition → Digit Processing: uses carry propagation
- Magnitude Subtraction → Digit Processing: uses borrow handling
- Magnitude Multiplication → Digit Processing: uses word operations
- Digit Processing → Normalization: produces canonical digits
- Signed Arithmetic → Normalization: canonicalizes result
- Normalization → Signed Magnitude: updates value
- Parsing and Output → Signed Magnitude: reads and emits magnitude
- Native Integer Boundary → Digit Processing: bounds native arithmetic
- Native Integer Boundary → Parsing and Output: limits conversion width
