---
tag: R8S821AD6T
kind: definition
name: Floating-point arithmetic
msc: [65G50, 65Y04]
defines: RTKRSC3KPH
uses: [5NPVX29Y0C, 0C4JS9RF5M]
sources:
  - url: https://en.wikipedia.org/wiki/Floating-point_arithmetic
---

## Definition

Fix [[integers|0C4JS9RF5M]] $\beta \ge 2$ (the *base*), $p \ge 1$ (the *precision*), and $e_{\min} < e_{\max}$.
A *floating-point number* of this system is $0$ or a real number of the form
$$x = \pm\, (d_0 . d_1 d_2 \ldots d_{p-1})_\beta \times \beta^{e} = \pm \left( \sum_{i=0}^{p-1} d_i \beta^{-i} \right) \beta^{e}.$$
Here the digits $d_i$ are integers with $0 \le d_i \le \beta - 1$, and the exponent $e$ is an integer with $e_{\min} \le e \le e_{\max}$.
The number is *normalized* if $d_0 \ne 0$.
Let $F$ be the set of these numbers.
Let $\mathrm{fl}$ be a [[rounding|5NPVX29Y0C]] to $F$ of the real numbers between $\min F$ and $\max F$, usually rounding to nearest.
*Floating-point arithmetic* replaces each operation $\circ \in \set{+, -, \times, /}$ on $x, y \in F$, whenever $x \circ y$ lies in this range, by
$$x \circledast y = \mathrm{fl}(x \circ y),$$
that is, the exact result rounded to $F$.

## Remarks

Example: with $\beta = 10$ and $p = 3$, the numbers $x = 1.23$ and $y = 4.56 \times 10^{-2}$ lie in $F$, and $x \oplus y = \mathrm{fl}(1.2756) = 1.28$ under rounding to nearest.
Non-example: with $\beta = 10$ and $p = 3$, the number $1.234$ is not in $F$, since it needs four significant digits.
Floating-point addition is commutative but not associative: with $\beta = 10$ and $p = 3$, $(1.00 \oplus 0.004) \oplus 0.004 = 1.00$, while $1.00 \oplus (0.004 \oplus 0.004) = 1.01$.
In the range of normalized numbers and with rounding to nearest, $x \circledast y = (x \circ y)(1 + \delta)$ with $\abs{\delta} \le \tfrac12 \beta^{1-p}$.
