{
  "id": "round-off-error",
  "title": "Round-off Error",
  "lang": "en",
  "source_lang": "en",
  "summary": "Round-off error is the discrepancy introduced when a number or arithmetic result is replaced by a nearby value representable with finite precision.",
  "category": "mathematics",
  "subcategory": "applied",
  "type": "concept",
  "aliases": [
    "Rounding error",
    "Roundoff error"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/round-off-error/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/round-off-error/",
      "json": "https://aiwiki.page/zh/round-off-error.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Round-off error is the difference between an exact numerical value and the finite-precision value used to represent it. It occurs when numbers are stored, converted between numerical formats, or produced by arithmetic operations whose exact results cannot be represented in the available format. In floating-point arithmetic, even a correctly implemented operation may therefore return an approximation rather than its exact mathematical result. The study of these errors is a central part of numerical analysis."
    },
    {
      "heading": "Origin and basic examples",
      "text": "A finite numerical format can represent only a limited set of numbers. Most real numbers lie outside that set, so storing them requires an approximation. This limitation also affects many simple rational numbers: a fraction has a terminating positional expansion only when its reduced denominator divides some power of the base.\n\nFor example, \\(1/10\\) terminates in decimal notation but repeats indefinitely in binary notation. Its representation in a finite binary floating-point format is consequently approximate. This explains why, in common binary64 arithmetic, evaluating \\(0.1+0.2\\) and printing enough decimal digits commonly produces \\(0.30000000000000004\\), rather than exactly \\(0.3\\).\n\nRound-off can arise at several distinct stages:\n\n- Input conversion: a decimal literal or measured input is converted to a representable machine value.\n- Arithmetic: an exact sum, product, quotient, or other result is rounded to the working format.\n- Storage or format conversion: a value held in a wider format is converted to a narrower one.\n- Output: a stored value is rounded to a specified number of displayed digits.\n\nThese stages need not produce the same kind or magnitude of error. Printing fewer digits changes the displayed approximation but does not necessarily change the underlying stored value.\n\nRound-off error is distinct from measurement uncertainty, which concerns knowledge of an observed quantity. An exactly specified mathematical input can still incur round-off when represented or processed numerically."
    },
    {
      "heading": "Absolute and relative error",
      "text": "Let \\(x\\) be an exact value and \\(\\widehat{x}\\) its approximation. Defining the signed error as approximation minus exact value gives\n\n\\[e=\\widehat{x}-x.\\]\n\nThe absolute error is\n\n\\[|e|=|\\widehat{x}-x|,\\]\n\nand, for \\(x\\ne 0\\), the relative error is\n\n\\[\\frac{|\\widehat{x}-x|}{|x|}.\\]\n\nAbsolute error measures the discrepancy in the same units as the quantity. Relative error measures it in proportion to the quantity’s magnitude. A fixed absolute error can therefore be negligible for a large value but substantial for a small one. Relative error is undefined when the exact value is zero and can be misleading near zero, where absolute error may be more informative."
    },
    {
      "heading": "Rounding rules and error bounds",
      "text": "A rounding rule specifies which representable value replaces an exact result. Common rules include rounding to the nearest representable number, rounding toward zero, and rounding toward positive or negative infinity. When two representable values are equally close, a tie-breaking rule is needed. “Ties to even” selects the value whose final retained digit is even.\n\nRounding to nearest normally introduces at most half the distance between the neighboring representable values surrounding the exact result. Directed rounding can introduce an error approaching the full spacing. Unlike fixed-point formats, floating-point formats generally have spacing that increases with magnitude, so their error is naturally described in relative terms.\n\nUnit roundoff\n\nFor a normalized floating-point format with base \\(\\beta\\) and \\(p\\) significand digits, the conventional unit roundoff for rounding to nearest is\n\n\\[u=\\frac{1}{2}\\beta^{1-p}.\\]\n\nA standard model is\n\n\\[\\operatorname{fl}(x)=x(1+\\delta), \\qquad |\\delta|\\le u,\\]\n\nwhere \\(\\operatorname{fl}(x)\\) denotes the rounded value. The model applies under suitable range conditions, in particular when \\(x\\) is in the normal range and rounding does not overflow.\n\nSimilarly, for an elementary arithmetic operation \\(\\circ\\),\n\n\\[\\operatorname{fl}(a\\circ b) =(a\\circ b)(1+\\delta), \\qquad |\\delta|\\le u,\\]\n\nprovided the exact result satisfies the required range conditions and the operation is correctly rounded.\n\nThe term machine epsilon is not used uniformly. It often denotes the gap between \\(1\\) and the next larger representable number, namely \\(\\beta^{1-p}\\), but some texts use it for unit roundoff. Under the gap convention, binary64 arithmetic has\n\n\\[\\varepsilon_{\\mathrm{mach}}=2^{-52}, \\qquad u=2^{-53}.\\]\n\nSubnormal values and range limitations\n\nSubnormal floating-point numbers extend representation toward zero with approximately constant absolute spacing. Their relative precision decreases as their magnitude decreases, so the same uniform relative-error bound does not apply throughout this region. Absolute-error bounds remain useful there.\n\nOverflow and underflow require separate treatment from ordinary rounding within the normal range. Overflow occurs when a result exceeds the format’s finite range; underflow concerns tiny results near zero, which may become subnormal or round to zero."
    },
    {
      "heading": "Propagation through a computation",
      "text": "A bound on one operation does not by itself describe the accuracy of an entire computation. Earlier errors become inputs to later operations and may be amplified, attenuated, or canceled.\n\nFor example, floating-point addition is generally not associative:\n\n\\[\\operatorname{fl}\\!\\left(\\operatorname{fl}(a+b)+c\\right) \\ne \\operatorname{fl}\\!\\left(a+\\operatorname{fl}(b+c)\\right).\\]\n\nIn binary64 arithmetic, taking \\(a=10^{16}\\), \\(b=-10^{16}\\), and \\(c=1\\), the first grouping gives \\(1\\), while the second gives \\(0\\). The small term is lost when added to a much larger value in the second grouping.\n\nThis matters in parallel computing, where changing the reduction tree used to sum many values can change the result without changing the mathematical expression.\n\nSummation bounds\n\nFor straightforward sequential summation of \\(n\\) floating-point inputs, a standard absolute-error bound is\n\n\\[\\left| \\widehat{s}-\\sum_{i=1}^{n}x_i \\right| \\le \\gamma_{n-1}\\sum_{i=1}^{n}|x_i|,\\]\n\nwhere\n\n\\[\\gamma_k=\\frac{ku}{1-ku}, \\qquad ku<1.\\]\n\nThis bound assumes the usual floating-point model and excludes problematic overflow or underflow. It concerns summation of the supplied machine values; conversion errors in the original data must be considered separately.\n\nThe bound also reveals why relative accuracy can be poor when positive and negative terms nearly cancel: the sum of the magnitudes can greatly exceed the magnitude of the final answer.\n\nRound-off errors are deterministic for a fixed sequence of operations and rounding rules. Treating them as independent, zero-mean random quantities can be useful in some analyses, but that is an additional modeling assumption, not a general property of floating-point computation."
    },
    {
      "heading": "Cancellation",
      "text": "Catastrophic cancellation occurs when subtraction of nearly equal approximate quantities exposes and magnifies their existing errors relative to the small difference.\n\nFor example, suppose exact values \\(a=1.2344\\) and \\(b=1.2343\\) are each rounded to four significant decimal digits. Both become \\(1.234\\), so their computed difference is zero even though\n\n\\[a-b=0.0001.\\]\n\nThe information has already been lost before subtraction. Subtraction itself may be exact for the rounded operands; the problem is that those operands no longer contain the digits needed to recover the small difference.\n\nCancellation is not always harmful. If the operands are sufficiently accurate, subtracting nearby values can produce an accurate result. The danger lies in the interaction between cancellation, preexisting error, and the sensitivity of the desired quantity.\n\nAlgebraically equivalent formulas can behave very differently. For positive, large \\(x\\), direct evaluation of\n\n\\[\\sqrt{x+1}-\\sqrt{x}\\]\n\nsubtracts nearly equal numbers. The equivalent expression\n\n\\[\\frac{1}{\\sqrt{x+1}+\\sqrt{x}}\\]\n\navoids that subtraction and is usually more accurate, provided the intermediate operations remain within range."
    },
    {
      "heading": "Conditioning and numerical stability",
      "text": "Two distinct ideas govern how round-off affects a result.\n\nConditioning describes the sensitivity of the mathematical problem to perturbations in its inputs. A condition number quantifies this sensitivity. For a differentiable scalar function \\(f\\), a local relative condition number is\n\n\\[\\kappa_f(x)= \\left| \\frac{x f'(x)}{f(x)} \\right|,\\]\n\nwhere \\(x\\) and \\(f(x)\\) are nonzero. A large value means that small relative input perturbations can cause much larger relative output changes.\n\nNumerical stability describes how an algorithm introduces and propagates errors. A backward-stable algorithm produces a result that is the exact solution of a nearby problem, with “nearby” measured using an appropriate error model.\n\nFor instance, a backward-stable solution of a linear system may satisfy\n\n\\[(A+\\Delta A)\\widehat{x}=b+\\Delta b,\\]\n\nwith small perturbations \\(\\Delta A\\) and \\(\\Delta b\\). If the original problem is ill-conditioned, even these small perturbations can lead to a substantial error in \\(\\widehat{x}\\).\n\nConsequently, a stable algorithm does not guarantee a highly accurate answer to an ill-conditioned problem. Conversely, an unstable algorithm can lose accuracy even when the underlying problem is well-conditioned."
    },
    {
      "heading": "Distinction from truncation error",
      "text": "Truncation error arises when an exact mathematical process is replaced by a finite approximation—for example, by cutting off an infinite series or replacing a derivative with a finite difference. Round-off error arises from finite-precision representation and arithmetic. Both often occur in the same calculation.\n\nFor the forward-difference approximation\n\n\\[f'(x)\\approx\\frac{f(x+h)-f(x)}{h},\\]\n\nthe truncation error is typically proportional to \\(h\\), assuming sufficient smoothness. Meanwhile, rounding and function-evaluation errors in the numerator may be amplified by division by \\(h\\). A simplified error model is\n\n\\[E(h)\\approx C_1h+C_2\\frac{u}{h},\\]\n\nwhere the constants depend on the function and its scale.\n\nReducing \\(h\\) initially improves the approximation, but eventually round-off can dominate. Under this simplified model, balancing the two terms gives a step size proportional to \\(\\sqrt{u}\\), with the appropriate dimensional and problem-dependent factors included. Thus, smaller steps or more iterations do not automatically produce more accurate results."
    },
    {
      "heading": "Methods for controlling round-off",
      "text": "Several techniques reduce or bound the effects of finite precision:\n\n- Higher precision: reduces unit roundoff and can preserve information lost at lower precision, though it increases computational or storage costs.\n- Stable reformulation: replaces an expression with a mathematically equivalent form less susceptible to cancellation or extreme intermediate values.\n- Scaling: adjusts magnitudes to reduce overflow and underflow risk. It does not by itself eliminate intrinsic ill-conditioning.\n- Pairwise summation: combines terms through a balanced tree, reducing the depth of rounding accumulation relative to sequential summation.\n- Compensated summation: tracks corrections for information lost during additions; Kahan summation is a prominent example.\n- Fused multiply-add: evaluates \\(ab+c\\) with one final rounding rather than separately rounding the multiplication and addition.\n- Interval arithmetic: uses outward rounding to enclose exact values within computed bounds, although repeated dependencies can make the enclosures wide.\n\nExact integer or rational arithmetic can avoid round-off for suitable operations, but the required storage and computation may grow substantially. It also does not automatically provide finite exact representations for general irrational or transcendental results.\n\nAccuracy and reproducibility are separate concerns. Fixing operation order and floating-point settings can make a calculation reproducible without making it accurate; increasing precision can improve accuracy while still permitting small differences across implementations."
    }
  ],
  "links": [
    "floating-point-arithmetic",
    "numerical-analysis",
    "real-number",
    "rational-number",
    "measurement-uncertainty",
    "parallel-computing",
    "condition-number",
    "mathematical-function",
    "numerical-stability",
    "system-of-linear-equations",
    "infinite-series",
    "derivative",
    "interval-arithmetic"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}