{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nFix an integer base $B \\ge 2$, in practice a power of $2$ such as $2^{64}$.\nIn *arbitrary-precision arithmetic* an [[integer|0C4JS9RF5M]] $a$ is stored as a sign and a list of digits $(a_0, \\ldots, a_{k-1})$.\nHere $0 \\le a_i \u003c B$ and\n$$\\abs{a} = \\sum_{i=0}^{k-1} a_i B^i,$$\nwhere the length $k$ is not fixed in advance and grows as needed.\nArithmetic operations on such lists return the exact integer result in the same form.\nRational numbers are stored as pairs of such integers.\nReal numbers are stored as [[floating-point|RTKRSC3KPH]] numbers $m \\cdot 2^{e}$, where $m$ and $e$ are such integers and the precision $p$ is chosen by the user.\n\n## Remarks\n\nExample: with $B = 10$, the integer $123456780$ is the list $(0, 8, 7, 6, 5, 4, 3, 2, 1)$; adding $1$ changes only $a_0$, while adding $999999999$ produces a list of length $10$.\nNon-example: IEEE binary64 arithmetic is not arbitrary-precision; its precision is fixed at $53$ bits, so $2^{53} + 1$ cannot be stored exactly.\nAddition of two $k$-digit numbers costs $O(k)$ digit operations, schoolbook multiplication costs $O(k^2)$, and Karatsuba multiplication costs $O(k^{\\log_2 3})$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "AS00YM4X7F",
    "kind": "definition",
    "msc": [
      "65Y04",
      "68W30"
    ],
    "name": "Arbitrary-precision arithmetic",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic"
      }
    ],
    "tag": "8Y4C6N09YQ",
    "uses": [
      "0C4JS9RF5M",
      "RTKRSC3KPH"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/8Y4C6N09YQ/",
  "links": [
    {
      "field": "defines",
      "target": "AS00YM4X7F"
    },
    {
      "field": "uses",
      "target": "0C4JS9RF5M"
    },
    {
      "field": "uses",
      "target": "RTKRSC3KPH"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/8Y4C6N09YQ.md",
  "msc": [
    "65Y04",
    "68W30"
  ],
  "name": "Arbitrary-precision arithmetic",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/8Y4/8Y4C6N09YQ.md",
  "status": null,
  "tag": "8Y4C6N09YQ",
  "uri": "m2://8Y4C6N09YQ",
  "url": "https://tamnd.github.io/math2/wiki/arbitrary-precision-arithmetic-definition/",
  "writing": {
    "tag": "8Y4C6N09YQ",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
