betaFeedback

WorksComputer Science

When Double Rounding is Correct

Abstract

Number libraries, which implement number formats and their arithmetic in software, are used to simulate hardware, making hardware behavior reproducible and thus verifiable and easier to design. However, modern machine learning accelerators are difficult to simulate, as they increasingly use specialized number formats that existing number libraries do not support. It is costly to extend these libraries using traditional methods: each combination of operation, format, and rounding mode typically requires a bespoke implementation. An easier way is to double round - compute at higher precision, then re-round - so that one high-precision kernel serves many formats, but double rounding is only known to be correct in select cases. We give a precise, efficiently checkable characterization of when double rounding is correct across many formats and rounding modes. Our result rests on a novel abstract number format that unifies fixed- and floating-point representations, reducing the correctness of double rounding to format containment: whether every value of one format is representable in another. We mechanized these results in Lean 4. In addition, we introduce a format inference algorithm that, given a sequence of operations, bounds each expression by a number format guaranteed to contain its result. We apply these insights in two ways. First, we present MPFX, a correctly-rounded, multi-precision number library that exploits correct double rounding to efficiently simulate many number formats. MPFX's correctly-rounded operations are up to 11x (mean: 6.05x) faster than MPFR's, and competitive with SoftFloat's - between 0.46x and 1.63x as fast (mean: 0.94x) - at the same precision. Second, in a case study, we implement a software simulation of a hardware specification using both SoftFloat and MPFX's primitives; the MPFX version is up to 13.5x faster.

Introduction

The growing importance of machine learning workloads has driven a rapid proliferation of new number formats [27, 32, 44, 53], including 8-, 6-, and even 4-bit floating-point formats, which improve performance and energy efficiency at the cost of accuracy. Fixed-function hardware units (e.g., tensor cores) consume these small formats and perform sequences of operations on them internally, using exact or high-precision arithmetic for intermediate computations. A developer exploring the space of new hardware designs (or reproducing or verifying existing ones) faces a challenge: general-purpose CPUs do not support many of these formats, requiring a software simulation for each new candidate design that reproduces its behavior exactly.

One way to emulate unusual number formats is to use a number library [21, 25, 37, 47, 64]. A number library simulates number formats using the available numerical capabilities of the programming environment—for example, the Berkeley SoftFloat library [25] implements IEEE 754 floating-point arithmetic using only machine integer operations. As trusted reference implementations, number libraries are the backbone of tools including floating-point expression rewriters [50, 57], math library generators [8, 11, 35, 38], and error analyzers [2, 15, 51, 59].

However, most number libraries support operations over a limited set of number formats, and extending these operations to new formats requires substantial expertise, careful design, and extensive validation [9]. Since a format is tightly coupled with its arithmetic and rounding behavior,

Authors’ Contact Information: Brett Saiki, [email protected], University of Washington and Intel, Seattle, Washington, USA; Bill Zorn, Intel, Folsom, CA, USA, [email protected]; Cynthia Richey, [email protected], University of Pennsylvania, Philadelphia, PA, USA; Zachary Tatlock, University of Washington, Seattle, WA, USA, [email protected]. a correct implementation of one format does not transfer to another: developers must construct a new implementation for every combination of format, operation, and rounding mode.

Double rounding is an alternative approach to building number libraries which relies on the high-precision arithmetic available on most modern processors (e.g., IEEE 754 double-precision floating-point). The idea is simple: to simulate a low-precision format, compute the high-precision result, then re-round to the target format. By separating arithmetic from rounding, a single high-precision kernel efficiently serves many number formats. But this works only when double rounding is correct—that is, when it yields the same result as rounding directly to the low-precision format. Prior work establishes this for particular pairs of rounding modes [5, 7, 39] or particular operations [18, 19, 54, 56], but the question remains: when is double rounding correct in general?

To answer this question, we introduce an abstract number format that captures both floating-point and fixed-point number formats; its parameterization permits an efficient, complete check for determining format containment—when every representable value in one number format is representable in another format. We show that correct double rounding reduces to a format containment check: it suffices that the intermediate format contain the target format, possibly with a few extra bits of precision (depending on the rounding modes involved). Our results extend prior work [5, 7, 39] to more rounding modes, to formats with a maximum value, and to special values and overflow. We mechanize all of these results in Lean 4 [17].

Beyond guaranteeing that double rounding is correct for individual operations, we show how our abstract number format lets us map a whole real-valued specification onto the finite operations available in a programming environment. In practice, machine learning accelerators rarely operate on small formats end-to-end; instead, these formats serve as inputs to longer computations, with intermediate steps using exact or high-precision arithmetic. A dot product over 8-bit OCP MX formats [53], for example, accumulates into an intermediate value requiring far more precision than its small inputs would suggest. We develop a methodology built on format inference, which bounds each intermediate computation by a format covering its full range of values; with format containment and correct double rounding, it justifies semantics-preserving rewrites that map unrounded or high-precision operations onto those available in the programming environment.

We apply our theory in two ways. First, we build MPFX, a correctly-rounded, multi-precision number library in C++ that is correct for any instance of our abstract number format whose required intermediate (§ 5) fits in the IEEE 754 double-precision floating-point format. It handles every format by correctly re-rounding a high-precision result, rather than through the per-format bespoke implementations that number libraries traditionally require. MPFX builds on four arithmetic backends—hardware floating-point, two existing number libraries, and custom kernels based on error-free transformations (EFTs) [46]. It is efficient: its correctly-rounded operations run up to 13.5×13.5 \times (mean: 6.40×6.40 \times) faster than MPFR, and are competitive with SoftFloat—between 0.44×0.44 \times and 1.62×1.62 \times as fast (mean: 0.84×0.84 \times). We compare to SoftFloat only on the formats SoftFloat is highly optimized for (e.g., single-precision floating point); MPFX remains competitive on those formats while supporting many more. Second, in a case study, we use format inference and correct double rounding to implement an algorithm from the OCP MX standard [53], first with SoftFloat and then with MPFX; our MPFX-based program is up to 13.3×13.3 \times faster than the SoftFloat version.

Concretely, this paper makes the following contributions:

  • We present an abstract number format (§ 4) that parameterizes fixed- and floating-point number formats and permits an efficient and complete check for format containment (§ 5.1).

  • We characterize when double rounding is correct, expressing sufficient conditions as format containment, and when it is incorrect no matter how wide the intermediate format (§ 5.2).

  • We present a methodology, built on format inference, for determining when dropping, inserting, or modifying a rounding is semantics-preserving (§ 6).

Subsequently, § 7 introduces MPFX and evaluates its performance, and § 8 presents our case study. § 9 describes limitations and future work; § 10 discusses related work; § 11 summarizes our conclusions. Our Lean mechanization is included as supplementary material. We transcribed the paper’s definitions and theorem statements into Lean by hand, then used large language models (Claude Opus 4.7 and 4.8) to mechanize the prose proofs of Appendix A.

Overview

The OCP MX standard [53] defines small number formats, as well as algorithms for efficient training and inference. These algorithms describe computations at a high level, but leave specific implementation details (e.g., the number formats and rounding modes involved) to the implementer. Figure 1 outlines an MX algorithm for computing a dot product over blocks, which is the fundamental unit of the standard—essentially a vector {Vi}\{V_i\} of numbers sharing a common scale factor, XX, where each number in the block is represented as Vi=X×PiV_i = X \times P_i. The dataflow diagram (right), which represents one iteration of the loop, is annotated with question marks where concrete choices of number format and rounding mode must be made before the behavior of the algorithm on hardware is fully specified. Each way of resolving these choices yields a different hardware design, trading numerical accuracy for cost in chip area and power1.

Figure 1. A dot product over MX blocks (left) and the dataflow diagram for a single loop iteration (right), which combines one block from AA and one from BB with the running accumulator CC to produce the updated CC. Both AA and BB are encoded as MX blocks where each block has a scale factor XiX_i and elements {Pi,j}\{P_{i,j}\}.

# dot product over MX blocks
def mx_dot(A, B):
    C = 0
    for (X_i^A, P_i^A), (X_i^B, P_i^B) in zip(A, B):
        C += X_i^A × X_i^B × ∑_{j=1}^{32} (P_{i,j}^A × P_{i,j}^B)
    return C

Consider an engineer modeling candidate accelerators in software. Before committing a design to silicon, they must check that their design choices yield acceptable numerical behavior when running training or inference. Figure 2 (left) describes a candidate that performs as few roundings as possible. It uses a single input format—say, the 8-bit MX format E5M2—and performs all intermediate computations exactly, rounding only at the final accumulation.

The MX dot product algorithms
def accurate_mx_dot(A, B):
    C = 0
    for (X_i^A, P_i^A), (X_i^B, P_i^B) in zip(A, B):
        X = mul_R,_ (X_i^A, X_i^B)
        V = 0
        for P_{i,j}^A, P_{i,j}^B in zip(P_{i,j}^A, P_{i,j}^B):
            t_1 = mul_R,_ (P_{i,j}^A, P_{i,j}^B)
            V = add_R,_ (V, t_1)
        t_2 = mul_R,_ (X, V)
        C = add_FP32,RNE (C, t_2)
    return C
def our_mx_dot_mpfx(A, B):
    C = 0
    for (X_i^A, P_i^A), (X_i^B, P_i^B) in zip(A, B):
        X = mul_FP64,RNE (rnd_FP64,RNE (X_i^A), rnd_FP64,RNE (X_i^B))
        V = 0
        for P_{i,j}^A, P_{i,j}^B in zip(P_{i,j}^A, P_{i,j}^B):
            t = mul_FP32,RNE (rnd_FP32,RNE (P_{i,j}^A), rnd_FP32,RNE (P_{i,j}^B))
            V = add_{A(∞,-32,2^{95}-2^{-32}),RNE} (V, rnd_{A(∞,-32,2^{95}-2^{-32}),RNE}(t))
        V_hi, V_lo = split(V, 40)
        t_2 = mul_FP64,RNE (X, rnd_FP64,RNE (V_hi))
        t_3 = mul_FP64,RNE (X, rnd_FP64,RNE (V_lo))
        C = add_3FP32,RNE (t_2, t_3, C)
    return C

Figure 2. The MX dot product: a fully specified algorithm (left); and its efficient MPFX implementation (right), using MPFX or hardware-supported operations, derived in § 8. Each operator fF,rmf_{F,rm} is annotated with its number format FF and rounding mode rmrm (an unrounded operation is denoted fR,_f_{R,\_}).

To model this candidate faithfully in software, the engineer faces an immediate obstacle: its operations do not exist in the programming environment. The specification computes with infinitely-precise operations, whereas the environment provides only rounded operations over a handful of formats. Faithfully simulating the design therefore means rewriting the program to replace each of its operations with one or more available ones. This requires knowing what format each intermediate value inhabits, and when such a replacement is semantics-preserving. § 6 shows how to accomplish this using format inference and correct double rounding (§ 5).

As it turns out, this candidate is impractical: despite its small inputs, the inner accumulator of the dot product in Figure 2 (left, line 8) requires 69 bits of precision—well beyond double precision (53 bits). A hardware architect is unlikely to build such an accumulator; they would accept some rounding error and narrow it to a more manageable width—say, 20 to 50 bits. But the accumulator is only one of the operations left unspecified by Figure 1: each has a number format and rounding mode to choose, and each combination is its own candidate. Today, exploring this space means constructing a faithful model for each candidate by hand, reasoning about its formats, and validating it individually. Established number libraries offer little relief: each supports only a fixed handful of formats, so any candidate outside them requires another bespoke implementation.

Our number library, MPFX, is built with flexibility in mind: it is correct for any instance of our abstract number format (§ 4) whose required intermediate fits in double precision, with performance comparable to efficient number libraries like SoftFloat [25] and FloppyFloat [64]. Rather than implementing each candidate from scratch, MPFX exploits cases where double rounding is correct, reusing a few high-precision kernels across many formats by re-rounding their results; we discuss the relevant theory in § 5.

In § 8, we map the specification in Figure 2 (left) to SoftFloat’s primitives, and show that targeting MPFX yields a more efficient implementation (right). Crucially, both implementations are semantically equivalent to the specification, yet they use only the operations the programming environment provides. The rest of this paper addresses the following central problem: Given a numerical specification, how do we construct a faithful yet efficient implementation?

What is a Number Library?

A number library simulates number formats—floating-point, fixed-point, posits, and more—beyond those offered by standard hardware or language runtimes. Number libraries are essential tools for analyzing numerical error in multi-precision numerical algorithms, exploring different implementation trade-offs, and verifying the correctness of numerical software and hardware. Despite the diversity of number formats they support, number libraries share common ideas: number formats define which values are representable (§ 3.1), and rounding specifies how to approximate unrepresentable values (§ 3.2). Ideally, rounding satisfies a correctness property (§ 3.3), which extends to compositions of roundings, or double roundings (§ 3.4). We close the section with a survey of existing number libraries (§ 3.5).

Number Formats

A number format defines a discrete set of values that approximate the real numbers. Examples of number formats include machine integers (e.g., 32-bit signed integers); fixed-point numbers; floating-point numbers [1, 27, 53] (e.g., IEEE 754 single-precision floating-point numbers, OCP MX floating-point numbers); posit numbers [23]; and logarithmic numbers [60]. In practice, number formats are accompanied by a finite encoding that maps between bit patterns and numerical values and possibly non-real values such as infinities or NaNs.

In this paper, we restrict our attention to dyadic numbers, or numbers of the form (−1)s×c×2exp(-1)^{s} \times c \times2^{\mathit{exp}} where s∈{0,1}s \in\{0,1\} is the sign, c∈Z≥0c \in\mathbb{Z}_{\ge0} is the significand, and exp∈Z\mathit{exp} \in\mathbb{Z} is the exponent. The set of dyadic numbers is denoted Z[12]\mathbb{Z}[\frac{1}{2}].2 We will consider number formats that are subsets of the dyadic numbers2; this covers the common number formats: floating-point, fixed-point, and integer number formats. A number format may also contain special values, which indicate an extremal (±∞\pm\infty) or undefined (NaN) result.

We denote the set of all possible number formats with F\mathbb{F}. Notice that our representation of dyadic numbers is redundant since c×2exp=2c×2exp−1c \times2^{\mathit{exp}} = 2c \times2^{\mathit{exp}-1}; that is, 3×22=6×21=12×203 \times2^{2} = 6 \times2^{1} = 12 \times2^{0} are all valid representations of the dyadic number 12. Let F∈FF \in\mathbb{F} be a number format. A dyadic number x∈Z[12]x \in\mathbb{Z}[\frac{1}{2}] is representable in FF when x∈Fx \in F. If x=(−1)s×c×2expx = (-1)^{s} \times c \times2^{\mathit{exp}}, the precision of xx is ⌈log⁡2(c+1)⌉\lceil\log_{2}(c+1) \rceil, which is the fewest binary digits that can encode cc. For y1,y2∈Fy_{1}, y_{2} \in F, we say that y1y_{1} and y2y_{2} are adjacent whenever there exists no intervening representable number.

Rounding

For any number format, there is a gap between any two adjacent representable values, a range of real numbers that are unrepresentable in the format. If we want to convert a real number in this gap to a number in the target format, we must round it to either the lesser or greater value. The choice between these options is governed by the rounding mode.

A rounding function rnd⁡F,rm\operatorname{rnd}_{F,\mathit{rm}} maps every real number x∈Rx \in\mathbb{R} to a representable value in the number format F∈FF \in\mathbb{F}. If xx is representable in FF, then rnd⁡F,rm(x)=x\operatorname{rnd}_{F,\mathit{rm}}(x)=x. Otherwise, there exist two adjacent representable values y1,y2∈Fy_{1}, y_{2} \in F such that y1<x<y2y_{1}<x<y_{2};3 the rounding mode rm\mathit{rm} decides whether rnd⁡F,rm(x)=y1\operatorname{rnd}_{F,\mathit{rm}}(x)=y_{1} or rnd⁡F,rm(x)=y2\operatorname{rnd}_{F,\mathit{rm}}(x)=y_{2}. We classify representable values as even or odd so that, for two adjacent representable values y1y_{1} and y2y_{2}, one is always even and the other odd.4

The IEEE 754 standard [1] defines five rounding modes: two that round to the nearest value (and differ in their tiebreaking behavior), and three that round in a fixed direction. The nearest rounding modes choose the representable value that is closest to xx. When xx is exactly halfway between y1y_{1} and y2y_{2}, a tiebreaking rule chooses which representable value to produce:

  • round to nearest, ties to even (RNE): tiebreak to the even value;

  • round to nearest, ties away from zero (RNA): tiebreak to the value with the larger magnitude.

The directed rounding modes choose the representable value irrespective of distance:

  • round towards positive infinity (RTP): choose the value closest to +∞+\infty;

  • round towards negative infinity (RTN): choose the value closest to −∞-\infty;

  • round towards zero (RTZ): choose the value with the smaller magnitude.

For this paper, we consider two other rounding modes:

  • round away from zero (RAZ): choose the value with the larger magnitude;

  • round to odd (RTO): choose the odd value.

The RTZ mode is the obvious counterpart to RAZ. The RTO mode is a subject of much research interest in recent decades [5, 6, 38]. For this paper, we will focus on RNE, RTZ, RAZ, and RTO since the specific tiebreaking rule of RNE and RNA has no effect in our analysis, and RTP acts as RAZ when x≥0x \ge0 and as RTZ otherwise, with RTN the opposite.

In practice, number formats have a maximum representable value bb. Let F^\hat{F} be FF with no maximum representable value or special values. Given functions σ:{+∞,−∞,NaN}→F\sigma: \{+\infty, -\infty, \mathrm{NaN}\} \to F and ω:{−1,+1}→F\omega: \{-1, +1\} \to F, rounding to FF is

rnd⁡F,rmσ,ω(x)={σ(x)if x∈{+∞,−∞,NaN},ω(sgn⁡(y))if ∣y∣>b,yotherwise,where y=rnd⁡F^,rm(x).\operatorname{rnd}_{F,rm}^{\sigma,\omega}(x) = \begin{cases} \sigma(x) & \text{if } x \in\{+\infty, -\infty, \mathrm{NaN}\},\\ \omega(\operatorname{sgn}(y)) & \text{if } |y| > b,\\ y & \text{otherwise}, \end{cases} \qquad\text{where } y = \operatorname{rnd}_{\hat{F},rm}(x).

We say xx overflows when ∣y∣>b|y| > b. We omit σ\sigma and ω\omega when clear from context. IEEE 754 [1] sets σ\sigma to the identity and ω(s)\omega(s) to s⋅∞s \cdot\infty or s⋅bs \cdot b, depending on the rounding mode and ss; OCP MX [49] may instead saturate, with σ(±∞)=ω(±1)=±b\sigma(\pm\infty) = \omega(\pm1) = \pm b.

Correct Rounding

So far, we have discussed rounding individual real numbers to a target number format. However, rounding often occurs as part of a computation: when we add two floating-point numbers, their sum may not be representable. We want a guarantee that numerical operations give the same result as performing the exact computation, then rounding.

Let f:Rn→Rf : \mathbb{R}^{n} \to\mathbb{R} be a function. An implementation of ff for a number format FF and rounding mode rmrm, denoted fF,rmf_{F,rm}, is correctly-rounded if it produces the rounded value of the exact result of ff. More formally, fF,rmf_{F,rm} is the composition of the exact function ff and a rounding function rnd⁡F,rm\operatorname{rnd}_{F,rm}:

fF,rm=rnd⁡F,rm∘f.f_{F,rm} = \operatorname{rnd}_{F,rm} \circ f.

Few languages and libraries offer comprehensive correct rounding. The IEEE 754 standard requires only that basic arithmetic (e.g., addition) be correctly rounded; in most languages, implementations of transcendental functions—for example, the exponent function exe^x—are not guaranteed to be correctly rounded. This lack of clear specification means that the results of numerical algorithms may vary across operating systems and languages, leading to higher than expected error. Requiring correct rounding in programming environments has strong benefits [9]: it provides a clear specification for the behavior of fF,rmf_{F,rm}; it ensures reproducible results across different implementations of fF,rmf_{F,rm}; and it bounds the numerical error introduced by rounding consistently.

Double Rounding

A double rounding is the composition of two rounding functions: for number formats F1F_1, F2F_2 and rounding modes rm1rm_1, rm2rm_2, a double rounding has the form rnd⁡F1,rm1∘rnd⁡F2,rm2\operatorname{rnd}_{F_1,rm_1} \circ\operatorname{rnd}_{F_2,rm_2}. A double rounding is correct when the intermediate rounding has no effect on the final result:

rnd⁡F1,rm1=rnd⁡F1,rm1∘rnd⁡F2,rm2.\operatorname{rnd}_{F_1,rm_1} = \operatorname{rnd}_{F_1,rm_1} \circ\operatorname{rnd}_{F_2,rm_2}.

Correct double rounding lets us safely re-round an already-rounded computation. Composing both sides of the identity with ff yields

rnd⁡F1,rm1∘f=rnd⁡F1,rm1∘rnd⁡F2,rm2∘f,\operatorname{rnd}_{F_1,rm_1} \circ f = \operatorname{rnd}_{F_1,rm_1} \circ\operatorname{rnd}_{F_2,rm_2} \circ f,

that is, fF1,rm1=rnd⁡F1,rm1∘fF2,rm2f_{F_1,rm_1} = \operatorname{rnd}_{F_1,rm_1} \circ f_{F_2,rm_2}: re-rounding the correctly-rounded result for F2F_2 produces the correctly-rounded result for F1F_1, for any function ff. Unfortunately, double roundings are not always correct roundings. For example, let x=1.26x = 1.26 be a rational number, F1F_1 be the E2M1 floating-point format from the OCP MX standard [53] and F2F_2 be the E4M3 floating-point format from the same standard. If rm1=rm2=RNErm_1 = rm_2 = \mathrm{RNE}, then

rnd⁡F1,rm1(x)=1.5,rnd⁡F2,rm2(x)=1.25,andrnd⁡F1,rm1(rnd⁡F2,rm2(x))=1\operatorname{rnd}_{F_1,rm_1}(x) = 1.5,\qquad\operatorname{rnd}_{F_2,rm_2}(x) = 1.25,\qquad\text{and}\qquad\operatorname{rnd}_{F_1,rm_1}\left(\operatorname{rnd}_{F_2,rm_2}(x)\right) = 1

so we have a clear counterexample. If instead rm1=rm2=RTZrm_1 = rm_2 = \mathrm{RTZ}, both expressions evaluate to 1.

A Brief Survey of Number Libraries

Number libraries package software implementations of number formats, rounding modes, and the operations defined over them. Each library must decide which formats and rounding modes to implement, as well as the correctness guarantees they provide. We survey three correctly-rounded libraries that make different choices across these dimensions.

The Berkeley SoftFloat [25] library models IEEE 754 arithmetic using only machine integer operations. It implements the required arithmetic for the four named IEEE 754 formats.5

The FloppyFloat [64] library simulates floating-point arithmetic using existing floating-point arithmetic for superior performance compared to SoftFloat. It models other rounding modes using techniques such as error-free transformations (EFTs) [46], requiring only the host system’s floating-point operations under the default rounding mode (RNE).

Lastly, the MPFR [21] library targets numerical analysis applications, modeling a more mathematical form of floating-point arithmetic with no strict correspondence to hardware floating point. The library supports arbitrary-precision floating point, allowing the user to set the number of binary digits at the cost of requiring a memory allocator. It provides a comprehensive set of correctly-rounded operations, including arithmetic, algebraic, and transcendental functions.

Unifying Number Formats

In this section, we introduce an abstract number format that encompasses both floating-point and fixed-point formats. Our key observation is that common number formats are not arbitrary sets of dyadic numbers; they exhibit significantly more structure. We exploit this structure by modeling a format’s representable values as the output of parameterized generators (§ 4.1), from which the abstract number format follows naturally (§ 4.2). In § 5, we will see how this abstraction allows us to efficiently reason about format containment and correct double rounding.

Generating Number Formats

To develop a unified abstract number format, we first construct generators for fixed-point and floating-point formats that produce all the numerical values in those formats, and then observe that these generators are similar. To start, we will consider formats that have no maximum value and therefore contain countably infinite representable values, but we will later impose a bound. We focus solely on the representable values themselves, not on their underlying encodings.6

In § 4.2, we discuss special values like infinity and NaN. Our formats have a single zero; we do not model signed zero.

Fixed-Point Number Formats. Fixed-point formats have representable values that are equidistant. In particular, the distance between adjacent representable values, also called the quantum, is a power of two7: q=2expq = 2^{\mathit{exp}}. The integers are a familiar instance with a quantum of q=1q = 1. The process for generating the fixed-point format with quantum qq is straightforward. First, we set ϑ=0\vartheta= 0 and produce 0. Then, we repeatedly increase vv by qq, producing +v+v and −v-v at each step. Figure 3 shows the result of this procedure: an approximation of the real line by a set of evenly-spaced, dyadic numbers with spacing q=2−2q = 2^{-2}. The crucial property of this generator is that every value it produces has the form ±c×2exp\pm c \times2^{\mathit{exp}}.

Representable values on the real line for a fixed-point format

Figure 3. Representable values on the real line for a fixed-point format with quantum q=2−2q = 2^{-2}. Fixed-point formats have representable values that are evenly spaced.

Floating-Point Number Formats. A floating-point number format arises naturally by filtering for values in a fixed-point format that satisfy a maximum precision constraint: each representable value must have some form (−1)s×c×2exp(-1)^s \times c \times2^{\mathit{exp}} where cc has precision at most p∈Z≥1p \in\mathbb{Z}_{\ge1}.

The procedure for generating representable floating-point values begins in an identical way to the fixed-point format; we repeatedly select values exactly qmin⁡=2expmin⁡q_{\min} = 2^{\mathit{exp}_{\min}} apart, starting from 0. Eventually, we encounter a number that, at first glance, seems to violate the precision constraint: ±2p×2expmin⁡\pm2^p \times2^{\mathit{exp}_{\min}} has a (p+1)(p+1)-digit significand. Fortunately, we can take advantage of our redundant representation of dyadic numbers; we can represent the number with ±2p−1×2expmin⁡+1\pm2^{p-1} \times2^{\mathit{exp}_{\min}+1} instead, which has a pp-digit significand. However, its successor has no such luck: ±(2p+1)×2expmin⁡\pm(2^p + 1) \times2^{\mathit{exp}_{\min}} can be represented with, at minimum, a (p+1)(p+1)-digit significand. The generator filters out this value and then steps again with the quantum qmin⁡q_{\min}. Repeating this generate-and-test procedure constructs the representable values of the floating-point number format with initial quantum qmin⁡q_{\min} and maximum precision pp. Figure 4 shows the representable values of this number format.

Representable values on the real line for a floating-point format

Figure 4. Representable values on the real line for a floating-point format with an initial quantum q=2−2q = 2^{-2} and a maximum precision of p=2p = 2.

At first, it may be surprising that this process generates the representable values of a floating-point format. Examining the number line reveals key properties of floating-point numbers. For ∣x∣≥1|x| \ge1, the spacing between representable values doubles after each power of two, and the number of representable values between powers of two [2e,2e+1)[2^e,2^{e+1}) is constant—in this example, the number is 2. For ∣x∣<1|x| < 1, the spacing is constant, a property called gradual underflow8. Importantly, since each floating-point format is a subset of some fixed-point format, the two number format families share the following property: every representable value is an integer multiple of the (initial) quantum.

The aforementioned generator is inefficient; the acceptance rate halves whenever vv crosses a power of two, eventually converging to zero. We can make a better generator that produces values without failure. Let vcut=2p−1×2expmin⁡+1=2expmin⁡+pv_{\mathrm{cut}} = 2^{p-1} \times2^{\mathit{exp}_{\min}+1} = 2^{\mathit{exp}_{\min}+p} be the cutoff after which the distance between representable values increases—for example, vcut=1v_{\mathrm{cut}} = 1 in Figure 4. At vcutv_{\mathrm{cut}}, the generator doubles the quantum to q=2expmin⁡+1q = 2^{\mathit{exp}_{\min}+1} and steps with the new quantum. Each subsequent value is representable with the form ±c×2expmin⁡+1\pm c \times2^{\mathit{exp}_{\min}+1} until we encounter the next power of two, 2vcut=±2p−1×2expmin⁡+22v_{\mathrm{cut}} = \pm2^{p-1} \times2^{\mathit{exp}_{\min}+2}, at which point, the quantum doubles again. This procedure continues indefinitely with the quantum doubling whenever the generator reaches the next power of two.

Bounded Formats. All the number formats described so far in this section represent an infinite set of dyadic numbers. In practice, however, most number formats are designed to be encodable in a fixed-length bit string, which necessarily limits them to a finite number of representable values. For example, the IEEE 754 standard explicitly defines floating-point formats that are encodable in 32 bits (binary32) and 64 bits (binary64). Because the set of representable values is finite, there must exist a largest representable magnitude.

Given a maximum representable value bb, all representable values of a number format satisfy ∣x∣≤b|x| \le b. However, some number formats are not symmetric: the largest positive and negative representable values may differ in magnitude. For example, machine integer types such as C’s int are asymmetric. In such cases, separate bounds must be specified for positive and negative values. If b+b^+ and b−b^- denote the positive and negative bounds, then b−≤x≤b+b^- \le x \le b^+.

Rounding to a bounded format proceeds as in § 3.2: we round without a maximum representable value, producing yy; if ∣y∣>b|y| > b, then rnd⁡F,rm(x)=ω(sgn⁡(y))\operatorname{rnd}_{F,rm}(x) = \omega(\operatorname{sgn}(y)).

Abstract Number Format

Fundamentally, the generators in § 4.1 differ in just one respect: whether the quantum increases. Notice that if we set p=∞p = \infty for the floating-point generator, it becomes a fixed-point generator: the value at which the quantum increases, vcut=∞v_{\mathrm{cut}} = \infty, is never reached. This suggests that fixed-point and floating-point formats are instances of a single parameterized format. Figure 5 shows the algorithm for this unified generator9.

Algorithm for generating representable values

Figure 5. An algorithm for generating the representable values of fixed-point and floating-point number formats, with or without a maximum representable value.

All number formats described by the generator are quantized, in the sense that they have a minimum step size between representable values. What number formats exist outside of this class of quantized number formats? Many number formats in F\mathbb{F} can be classified by generator parameters (p,q,b)(p, q, b), where q=0q = 0 denotes no minimum quantum. Figure 6 classifies these formats by three properties of their parameters: quantized (q>0q > 0), precision-bound (p<∞p < \infty), and bounded (b<∞b < \infty); number formats may satisfy any combination of these properties.

Venn diagram classifying number formats by generator parameters

Figure 6. Classifying number formats by their generator parameters (p,q,b)(p,q,b) into quantized (q>0)(q > 0), precision-bound (p<∞)(p < \infty), or bounded (b<∞)(b < \infty) number formats. Our abstract number format A\mathcal{A} captures number formats in the shaded region: either quantized (q>0)(q > 0) or precision-bound (p<∞)(p < \infty) number formats.

Of the common number formats in F\mathbb{F}, few lack a minimum quantum. Formal proofs of floating-point arithmetic often ignore the effects of overflow and underflow, allowing the exponent to be any integer—these floating-point formats are neither quantized nor bounded10. Posit numbers [23] fall outside this classification since no choice of parameters describes them: their precision varies with magnitude. The remaining two regions—unquantized, bounded floating-point formats and bounded dyadic numbers—are absent in real-world usage; we are unsure of their potential use.

The three parameters pp, qq, and bb determine the numerical values of an abstract number format unifying fixed-point and floating-point formats. Since every quantum is a power of two, we can equivalently represent it using its exponent, expexp, where q=2expq = 2^{exp}; if the format has no minimum quantum, then exp=−∞exp = -\infty. A fourth parameter, SS, enumerates the special values of the format. We denote this abstract number format by A\mathcal{A} and an instance by A(p,exp,b,S)\mathcal{A}(p,exp,b,S). For any number format A(p,exp,b,S)\mathcal{A}(p,exp,b,S), we will call p∈Z≥1∪{∞}p \in\mathbb{Z}_{\ge1} \cup\{\infty\} the maximum precision of the format, exp∈Z∪{−∞}exp \in\mathbb{Z} \cup\{-\infty\} the exponent of the minimum quantum, b∈A(p,exp,∞)∪{∞}b \in\mathcal{A}(p,exp,\infty) \cup\{\infty\} the maximum representable value, and S⊆{+∞,−∞,NaN}S \subseteq\{+\infty,-\infty,\mathrm{NaN}\} the special values11. When a format has no special values, we write A(p,exp,b)\mathcal{A}(p,exp,b) for A(p,exp,b,∅)\mathcal{A}(p,exp,b,\emptyset). Notice that we could let bb be any dyadic number. However, A(p,exp,b)\mathcal{A}(p,exp,b) is equivalent to any A(p,exp,b′)\mathcal{A}(p,exp,b') such that b≤b′<next⁡p,exp(b)b \le b' < \operatorname{next}_{p,exp}(b) where next⁡p,exp(b)\operatorname{next}_{p,exp}(b) produces the subsequent representable value after bb in A(p,exp,∞)\mathcal{A}(p,exp,\infty). Thus, the restriction that b∈A(p,exp,∞)∪{∞}b \in\mathcal{A}(p,exp,\infty) \cup\{\infty\} does not affect which number formats we can represent and simplifies the theory.

We place three additional restrictions on the parameters of A\mathcal{A}. First, an instance must be quantized (exp>−∞exp > -\infty) or precision-bound (p<∞p < \infty), corresponding to the shaded region of Figure 6. Second, an instance must be non-trivial, representing at least one nonzero value. Third, we disallow A(1,−∞,b)\mathcal{A}(1,-\infty,b), whose representable values are zero and ±2k\pm2^k for all 2k≤b2^k \le b: every significand is c=1c = 1 and there is no smallest positive value, so the even/odd classification of § 3.2 is ill-defined12. Table 1 lists common number formats expressed as instances of our abstract number format A\mathcal{A}. If FF has a defining standard, the standard is listed alongside it. The abstract number format A\mathcal{A} covers a wide range of real number formats, including IEEE 754 floating-point formats, machine learning formats like Nvidia’s TensorFloat-32 format [45], Google’s bfloat16 format [32], and the OCP MX formats E5M2 and E4M3 [53]. It also covers fixed-point formats, machine integer types, and arbitrary-precision formats like the integers, Z\mathbb{Z}, and MPFR floating-point numbers. Formats encode different special values: the IEEE 754 formats and their derivatives have both infinities and

A(p,exp,b,S)\mathcal{A}(p, exp, b, S)Sourceppexpexpbbbb (approx.)SS
binary64IEEE 754 [1]53−1074(253−1)×2971(2^{53} - 1) \times2^{971}1.798×103081.798 \times10^{308}{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}
binary32IEEE 75424−149(224−1)×2104(2^{24} - 1) \times2^{104}3.403×10383.403 \times10^{38}{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}
TensorFloat-32 [45]Nvidia11−136(211−1)×2117(2^{11} - 1) \times2^{117}3.401×10383.401 \times10^{38}{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}
bfloat16 [32]Google Brain8−133(28−1)×2120(2^8 - 1) \times2^{120}3.390×10383.390 \times10^{38}{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}
E5M2OCP MX [53]3−16(23−1)×213(2^3 - 1) \times2^{13}57344{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}
E4M3OCP MX4−9(24−2)×25(2^4 - 2) \times2^5448{NaN}\{\mathrm{NaN}\}
E2M1OCP MX2−1(22−1)×21(2^2 - 1) \times2^16∅\varnothing
int8_t-∞\infty0(27−1)×20(2^7 - 1) \times2^0127∅\varnothing
fixed<−4,8><-4,8>-∞\infty−4(27−1)×2−4(2^7 - 1) \times2^{-4}7.9375∅\varnothing
fixed<4,8><4,8>-∞\infty4(27−1)×24(2^7 - 1) \times2^42032∅\varnothing
Z\mathbb{Z}-∞\infty0∞\infty∞\infty∅\varnothing
(default)MPFR [21]53−∞-\infty∞\infty∞\infty{±∞,NaN}\{\pm\infty, \mathrm{NaN}\}

Table 1.

Table 1. Common number formats expressed as instances of A\mathcal{A}. The number format fixed<s,n><s,n> is a signed nn-bit integer implicitly scaled by 2s2^s. Since A\mathcal{A}’s bound is symmetric, signed integer and fixed-point types omit their most negative value (e.g., −128 for int8_t).

NaN, as does MX E5M2; MX E4M3 has only NaN; and MX E2M1 and the integer and fixed-point formats have neither. Importantly, the parameters exactly determine the set of representable values within the number format.

Comparison to Flocq. Flocq [7] takes a more general approach to unifying fixed- and floating-point formats. Its generic format is parameterized by a radix β\beta and an exponent function fexp that sets the quantum between consecutive powers of β\beta: a real number xx with ∣x∣∈[βe−1,βe)\lvert x\rvert\in[\beta^{e-1}, \beta^e) is representable when xx is an integer multiple of βfexp⁡(e)\beta^{\operatorname{fexp}(e)}. Fixed point (FIX) is fexp⁡(e)=exp\operatorname{fexp}(e) = exp; floating point (FLX) with unbounded exponents is fexp⁡(e)=e−p\operatorname{fexp}(e) = e - p; and floating point with a minimum quantum (FLT), as in IEEE 754, is fexp⁡(e)=max⁡(e−p,exp)\operatorname{fexp}(e) = \max(e - p, exp). In radix two, A(p,exp,∞)\mathcal{A}(p, exp, \infty) is equivalent to the generic format with fexp⁡(e)=max⁡(e−p,exp)\operatorname{fexp}(e) = \max(e - p, exp), which is FIX when p=∞p = \infty and FLX when exp=−∞exp = -\infty; A(p,exp,b)\mathcal{A}(p, exp, b) further restricts it to ∣x∣≤b\lvert x\rvert\le b. In § 5, we show how our particular parameterization reduces format containment, and with it correct double rounding, to an efficient check on pp, expexp, and bb.

Format Redundancy. The parameters do not uniquely determine the set of representable values; there exists a redundancy in specifying number formats. Consider the fixed-point format A(∞,−2,1)\mathcal{A}(\infty, -2, 1) and the floating-point format A(2,−2,1)\mathcal{A}(2, -2, 1), each a subset of the fixed-point and floating-point number format examples in § 4.1, respectively. If we enumerate the representable values, we obtain the set {0,±1/4,±1/2,±3/4,±1}\{0, \pm1/4, \pm1/2, \pm3/4, \pm1\} for both number formats. We see that the quantum never increases for the floating-point case since the cutoff νcut=1\nu_{\mathrm{cut}} = 1 is never exceeded.

We therefore classify A(2,−2,1)\mathcal{A}(2, -2, 1) as a degenerate floating-point format since the precision constraint p=2p = 2 is unused. In fact, A(2,−2,1)=A(3,−2,1)=⋯=A(∞,−2,1)\mathcal{A}(2, -2, 1) = \mathcal{A}(3, -2, 1) = \cdots= \mathcal{A}(\infty, -2, 1). Thus, we see another link between fixed-point and floating-point formats: every bounded, fixed-point number format is equivalent to infinitely many degenerate, floating-point number formats. Consequently, the classes of Figure 6 follow the chosen parameters rather than the set of values: A(∞,−2,1)\mathcal{A}(\infty, -2, 1) is not precision-bound, yet A(2,−2,1)\mathcal{A}(2, -2, 1) is.

This observation is particularly relevant for emerging machine learning number formats, where there is increasing pressure to reduce bitwidths for efficiency. For example, the MX E2M1 format, A(2,−1,6)\mathcal{A}(2, -1, 6), is only four bits wide. As number formats continue to shrink, implementers must contend with floating-point formats essentially becoming fixed-point formats. At the extreme, models such as BitNet [40, 62] achieve competitive accuracy with FP16 transformer architectures while constraining weights to {−1,+1}\{-1, +1\} or {−1,0,+1}\{-1, 0, +1\}.

Format Containment and Correct Double Rounding

Having defined an abstract number format, A\mathcal{A}, we now present two applications. First, for any two instances of A\mathcal{A}, we give an efficient, complete check for deciding format containment—that is, whether one number format is a subset of the other (§ 5.1). Second, we use format containment to characterize when double rounding is correct (§ 5.2). Finally, we show how correct double rounding enables a modular approach to building correctly-rounded number libraries by extending existing number libraries to support new number formats (§ 5.3). We have mechanized this section’s results in Lean [17]; Appendix A of our supplementary materials presents prose proofs.

Format Containment

How can we determine whether one number format is a subset of another? Naively, since format containment is just the subset relation F1⊆F2F_1 \subseteq F_2, we could check if every value in F1F_1 is in F2F_2. In particular, if both F1F_1 and F2F_2 are quantized instances of A\mathcal{A}, then we could run the generators described in § 4.1, enumerate all possible values in both formats, and check if each value in F1F_1 is also in F2F_2. For small, finite number formats—like those in machine learning—this approach wouldn’t necessarily take a long time13. Instead, we present an efficient check directly on the parameters of A\mathcal{A}, without enumerating representable values.

Let F1=A(p1,exp⁡1,b1,S1)F_1 = \mathcal{A}(p_1, \operatorname{exp}_1, b_1, S_1) and F2=A(p2,exp⁡2,b2,S2)F_2 = \mathcal{A}(p_2, \operatorname{exp}_2, b_2, S_2). Figure 7 presents the two judgments for determining when F1⊆F2F_1 \subseteq F_2. The first rule, A\mathcal{A}-Contains-Prec covers the majority of the cases, but is too restrictive for degenerate floating-point formats (or equivalently, bounded fixed-point formats). For these cases, A\mathcal{A}-Contains-Sub provides an alternative containment test.

Format containment rules

Figure 7. Format containment rules

A\mathcal{A}-Contains-Prec says: if F2F_2 has at least as much precision (p1≤p2p_1 \le p_2), at least as small a minimum quantum (exp⁡1≥exp⁡2\operatorname{exp}_1 \ge\operatorname{exp}_2), at least as large a bound (b1≤b2b_1 \le b_2), and every special value of F1F_1 (S1⊆S2S_1 \subseteq S_2), then F1⊆F2F_1 \subseteq F_2. The conditions b1≤b2b_1 \le b_2 and S1⊆S2S_1 \subseteq S_2 are clearly necessary; otherwise, b1∉F2b_1 \notin F_2 or S1⊈F2S_1 \not\subseteq F_2. Since every value in F2F_2 is a multiple of 2exp⁡22^{\operatorname{exp}_2}, it must be the case that exp⁡1≥exp⁡2\operatorname{exp}_1 \ge\operatorname{exp}_2. Finally, p1≤p2p_1 \le p_2 captures the relative precision of the two formats. Intuitively, any value with a p1p_1-digit binary significand is also expressible with a p2p_2-digit significand by padding with trailing zero digits and adjusting the exponent accordingly. Therefore, under these four conditions, every value representable in F1F_1 is also representable in F2F_2.

For degenerate floating-point formats, the maximum precision has no effect on the set of representable values, yet the precision test of A\mathcal{A}-Contains-Prec may fail. In these cases, A\mathcal{A}-Contains-Sub applies a different test: b1≤2exp⁡1+p2b_1 \le2^{\operatorname{exp}_1+p_2}. Every representable value of F1F_1 is a multiple of 2exp⁡12^{\operatorname{exp}_1}, and F2\mathcal{F}_2 represents every multiple of 2exp⁡12^{\operatorname{exp}_1} up to 2exp⁡1+p22^{\operatorname{exp}_1+p_2}. Therefore, b1≤2exp⁡1+p2b_1 \le2^{\operatorname{exp}_1+p_2} ensures that every representable value of F1\mathcal{F}_1 is also representable in F2\mathcal{F}_2.

The two rules are also complete:

Lemma 5.1. For any instances F1\mathcal{F}_1 and F2\mathcal{F}_2 of A\mathcal{A}, F1⊆F2\mathcal{F}_1 \subseteq\mathcal{F}_2 if and only if A\mathcal{A}-Contains-Prec or A\mathcal{A}-Contains-Sub applies.

We now prove that if F1⊆F2\mathcal{F}_1 \subseteq\mathcal{F}_2, then one of the two rules applies. Since b1∈F1b_1 \in\mathcal{F}_1 and S1⊆F1S_1 \subseteq\mathcal{F}_1, we have b1≤b2b_1 \le b_2 and S1⊆S2S_1 \subseteq S_2; since F1\mathcal{F}_1 is non-trivial, 2exp⁡1∈F12^{\operatorname{exp}_1} \in\mathcal{F}_1, so exp⁡1≥exp⁡2\operatorname{exp}_1 \ge\operatorname{exp}_2. If p1≤p2p_1 \le p_2, A\mathcal{A}-Contains-Prec applies. Otherwise, the value (2p2+1)×2exp⁡1(2^{p_2} + 1) \times2^{\operatorname{exp}_1} needs p2+1p_2 + 1 digits, so it lies outside F2\mathcal{F}_2 and must therefore lie outside F1\mathcal{F}_1’s bound; as b1b_1 is representable in A(p1,exp⁡1,∞)\mathcal{A}(p_1, \operatorname{exp}_1, \infty), this forces b1≤2exp⁡1+p2b_1 \le2^{\operatorname{exp}_1+p_2}, and A\mathcal{A}-Contains-Sub applies. Appendix A gives the full proof, including the cases b1=∞b_1 = \infty and exp⁡1=−∞\operatorname{exp}_1 = -\infty.

Through the correspondence with Flocq’s generic format (§ 4.2), the inclusion lemmas14 of Flocq [7] also establish the soundness of both rules, but not their completeness, and leave the user a side condition on the formats’ exponent functions to prove; Figure 7 reduces it to comparisons of parameters, including the bound. Moreover, both of these tests run in constant-time relative to the number of representable values in A(p1,exp⁡1,b1)\mathcal{A}(p_1, \operatorname{exp}_1, b_1), making them amenable to static analysis. The parameters of A\mathcal{A} bound the set of representable values and the distribution of representable values.

Correct Double Rounding

Recall from § 3.4 that, for number formats F1\mathcal{F}_1, F2\mathcal{F}_2 and rounding modes rm1rm_1, rm2rm_2, the double rounding rnd⁡F1,rm1∘rnd⁡F2,rm2\operatorname{rnd}_{\mathcal{F}_1,rm_1} \circ\operatorname{rnd}_{\mathcal{F}_2,rm_2} is correct whenever rnd⁡F1,rm1=rnd⁡F1,rm1∘rnd⁡F2,rm2\operatorname{rnd}_{\mathcal{F}_1,rm_1} = \operatorname{rnd}_{\mathcal{F}_1,rm_1} \circ\operatorname{rnd}_{\mathcal{F}_2,rm_2}: when F2\mathcal{F}_2 has no observable effect on the final answer. When is this true? Intuitively, it should be true when the intermediate rounding does not perturb its input too much, so that the final rounding makes the same choice it would have made on the original value. In this section, we show how this intuition can be formalized as a format containment check, with the required precision depending on the rounding modes involved.

We begin by characterizing how much information a rounding preserves; this directly determines the preconditions for correct double rounding. Rounding a real number xx to an instance of A\mathcal{A} proceeds in two steps: split the significand of xx at a position determined by xx, pp, and exp⁡\operatorname{exp}—we say the rounding rounds to the ww digits it retains—and then adjust the retained digits based on the discarded digits and the rounding mode (e.g., forcing the last digit odd under RTO). The rounding mode plays no role in the first step. Formally:

Lemma 5.2. Let A(p,exp⁡,b)\mathcal{A}(p,\operatorname{exp},b) be a number format, rmrm be any rounding mode, and x∈Rx \in\mathbb{R} be a real number. The number of digits rounded A(p,exp⁡,b),rm(x)\mathcal{A}(p,\operatorname{exp},b),rm(x) rounds to is a function of pp, exp⁡\operatorname{exp}, and xx.

This allows us to write w1w_1 and w2w_2 for the number of digits we round to when rounding to F1\mathcal{F}_1 and F2\mathcal{F}_2. Lemma 5.3 provides the relationship between w1w_1 and w2w_2:

Lemma 5.3. Let x∈Rx \in\mathbb{R} be a nonzero real number and k>0k > 0 be an integer. Suppose rounding to A(p,exp⁡,b)\mathcal{A}(p,\operatorname{exp},b) rounds to w1w_1 digits. Rounding to A(p+k,exp⁡−k,b)\mathcal{A}(p+k,\operatorname{exp}-k,b) rounds to w2=w1+kw_2 = w_1 + k digits.

From here, it follows naturally that, if F1⊆F2\mathcal{F}_1 \subseteq\mathcal{F}_2, then w1≤w2w_1 \le w_2. For double roundings where both rounding modes are the same—specifically for RAZ, RTO, and RTZ—this is sufficient; correct double rounding reduces to a simple format containment check on F1\mathcal{F}_1 and F2\mathcal{F}_2. However, in cases where RTO is used as the intermediate rounding and a different rounding mode—RTZ, RAZ, or RNE—is the final rounding mode, the picture is slightly more complicated. In these cases, we add one or two bits of padding to the intermediate format, in accordance with the following lemma:

Lemma 5.4. Let x′x' be the result of rounding xx to precision w+kw+k under RTO, where k≥1k \ge1. Then xx is representable at precision ww if and only if x′x' is representable at precision ww. If xx is unrepresentable at precision ww and y1<x<y2y_1 < x < y_2 are the two adjacent representable values at precision ww that are closest to xx, then y1<x′<y2y_1 < x' < y_2.

There are sixteen pairings of rounding modes for the intermediate and final roundings over RNE, RAZ, RTZ, and RTO. Of these, Figure 8 lists the six combinations that guarantee correct double rounding, along with the conditions under which they hold. The first six rules decide when rounding to F2F_2 under rm2rm_2 is a safe intermediate for rounding to F1F_1 under rm1rm_1, written ⟨F1,rm1⟩▹⟨F2,rm2⟩\langle F_1,rm_1\rangle\triangleright\langle F_2,rm_2\rangle: rounding a real number through F2F_2 matches rounding it directly to F1F_1, or both overflow. Their bounds on b2b_2 ensure that F2F_2 overflows only when F1F_1 does.

Correct double rounding rules

Figure 8. Correct double rounding. The first six rules check that rounding a real number through F2F_2 matches rounding it directly to F1F_1, or both overflow (⟨F1,rm1⟩▹⟨F2,rm2⟩\langle F_1,rm_1\rangle\triangleright\langle F_2,rm_2\rangle). Rule RND-DOUBLE adds that special values and overflow compose.

RND-DOUBLE extends correctness to every input when special values compose (rnd⁡F1,rm1∘σ2=σ1\operatorname{rnd}_{F_1,rm_1} \circ\sigma_2 = \sigma_1) and overflow composes (rnd⁡F1,rm1∘ω2=ω1\operatorname{rnd}_{F_1,rm_1} \circ\omega_2 = \omega_1). IEEE 754’s σ\sigma and ω\omega compose for every rule but RND-RTO-RTZ: the intermediate RTO rounding overflows to ±∞\pm\infty (our convention, since IEEE 754 has no RTO) and the final RTZ rounding returns ±∞\pm\infty unchanged, whereas rounding directly under RTZ overflows to ±b1\pm b_1; an intermediate that saturates instead (ω2(±1)=±b2\omega_2(\pm1) = \pm b_2) restores it. Longer chains of roundings reduce pairwise: if rounding through F3F_3 into F2F_2 and through F2F_2 into F1F_1 each satisfy RND-DOUBLE, then rnd⁡F1,rm1∘rnd⁡F2,rm2∘rnd⁡F3,rm3=rnd⁡F1,rm1\operatorname{rnd}_{F_1,rm_1} \circ\operatorname{rnd}_{F_2,rm_2} \circ\operatorname{rnd}_{F_3,rm_3} = \operatorname{rnd}_{F_1,rm_1}.

The first three rules (RND-RTZ-RTZ, RND-RAZ-RAZ, RND-RTO-RTO) apply when both roundings use the same mode and reduce to a single containment check. RND-RTZ-RTZ and RND-RAZ-RAZ are well known; CPFloat [18], for example, notes that double rounding under a directed rounding mode is always correct. For RTZ, truncating to w2w_2 digits then w1w_1 digits equals truncating directly to w1w_1 when w1≤w2w_1\leq w_2—guaranteed by Lemma 5.3. Similar arguments apply to the RAZ and RTO modes. The RND-RTO-RTO rule also requires p2≥2p_2\geq2 to avoid parity mismatches when both formats have one bit of precision.

The remaining rules—RND-RTO-RTZ, RND-RTO-RAZ, and RND-RTO-RNE—all use RTO as the intermediate rounding. Boldo and Melquiond [5] prove RND-RTO-RNE and remark, without proof, that the same intermediate serves any final rounding mode; RLIBM-ALL [39] applies this with two extra bits for every mode. Our rules make this precise and show that directed final modes need only one extra bit, and RTO none. The first two rules share the same premise, ensuring w1+1≤w2w_1+1\leq w_2. Under that condition, Lemma 5.4 guarantees that any (un)representable value in A(p1,exp⁡1,b1)\mathcal{A}(p_1,\exp_1,b_1) is still (un)representable after the intermediate rounding.

For RND-RTO-RNE, a slightly different premise instead guarantees that w1+2≤w2w_1+2\leq w_2. The additional digit preserves halfway cases, which is necessary to correctly round under RNE. Flocq mechanizes their theorem as round_N_odd [7]. Stated over A\mathcal{A} with our bound condition, it reads: for floating-point formats A(p1,exp⁡1,b1)\mathcal{A}(p_1,\exp_1,b_1) and A(p2,exp⁡2,b2)\mathcal{A}(p_2,\exp_2,b_2), if 2≤p1≤p2−22\leq p_1\leq p_2-2, exp⁡1≥exp⁡2+2\exp_1\geq\exp_2+2, and next⁡p1+1,exp⁡1−1(b1)≤b2\operatorname{next}_{p_1+1,\exp_1-1}(b_1)\leq b_2, then

rnd⁡A(p1,exp⁡1,b1),RNE=rnd⁡A(p1,exp⁡1,b1),RNE∘rnd⁡A(p2,exp⁡2,b2),RTO.\operatorname{rnd}_{\mathcal{A}(p_1,\exp_1,b_1),\mathrm{RNE}}=\operatorname{rnd}_{\mathcal{A}(p_1,\exp_1,b_1),\mathrm{RNE}}\mathbin{\circ}\operatorname{rnd}_{\mathcal{A}(p_2,\exp_2,b_2),\mathrm{RTO}}.

Their bound condition is slightly weaker: b2b_2’s overflow threshold need only be at least b1b_1’s.

The other ten pairings of rounding modes do not support correct double rounding in general. The construction applies to any F1⊆F2F_1\subseteq F_2 assuming that no rounding overflows. Let yy be an even representable value of F1F_1 with odd neighbors y−<y<y+y^{-}<y<y^{+}, and let δ\delta be a quarter of the quantum between F2F_2’s representable values on the relevant side of yy. For each pairing (Table 2), xx sits just past yy, or just past the halfway point to a neighbor. The intermediate rounding maps xx to yy, or to the yy-side of the halfway point, so the double rounding returns the even yy rather than the odd neighbor that direct rounding gives. Under the RTZ-RAZ pairing, for instance, x=y+δx=y+\delta truncates to yy under RTZ and stays there under RAZ, whereas rnd⁡F1,RAZ(x)=y+\operatorname{rnd}_{F_1,\mathrm{RAZ}}(x)=y^{+}. Since δ\delta shrinks as F2F_2 grows, xx only approaches yy: a larger intermediate format never helps.

xxrnd⁡F1,rm1(x)\operatorname{rnd}_{F_1,r m_1}(x)rnd⁡F1,rm1(rnd⁡F2,rm2(x))\operatorname{rnd}_{F_1,r m_1}(\operatorname{rnd}_{F_2,r m_2}(x))Double roundings rm2r m_2-rm1r m_1
y−δy-\deltay−y^{-}yyRNE-RTZ, RAZ-RTZ, RAZ-RTO, RNE-RTO
y+δy+\deltay+y^{+}yyRNE-RAZ, RTZ-RAZ, RTZ-RTO
m±δm\pm\deltay+y^{+}yyRTZ-RNE, RAZ-RNE, RNE-RNE

Table 2. Counterexamples for the ten unsound double roundings rm2r m_2-rm1r m_1 (rm2r m_2 intermediate, rm1r m_1 final). Here yy is an even value of F1F_1 with odd neighbors y−<y<y+y^{-}<y<y^{+}, δ\delta is a quarter of F2F_2’s spacing near yy, and mm is the halfway point just above yy (for RTZ-RNE) or just below it (for RAZ-RNE, RNE-RNE). All require only F1⊆F2F_1\subseteq F_2, except RNE-RNE, which requires A(p1+1,exp⁡1−1,b1)⊆A(p2,exp⁡2,b2)\mathcal{A}(p_1+1,\exp_1-1,b_1)\subseteq\mathcal{A}(p_2,\exp_2,b_2) to ensure m∈F2m\in F_2.

As the intermediate rounding, RTO supports correct double rounding for all four final modes, at the cost of at most two extra bits of precision. The directed modes RTZ and RAZ support double rounding only when the intermediate and final modes agree, and RNE-despite being the most popular, and often the only, rounding mode available in programming environments—permits it only in trivial cases (e.g., F2∩[−b1,b1]=F1F_2\cap[-b_1,b_1]=F_1, on inputs where neither rounding overflows), even when the intermediate format is made arbitrarily large.

Prior work exploits this property, using RTO whenever intermediate results must later be safely re-rounded [6, 38, 52]. We appeal to this same property to build a modular number library: a single round-to-odd kernel, evaluated in high enough precision, re-rounds to a correctly-rounded result under any final rounding mode. Rather than a separate implementation for each, MPFX computes its high-precision intermediates in RTO (§ 7).

Modular Number Libraries

Whenever double rounding is correct, we can implement a correctly-rounded function by combining higher-precision computation with rounding to the target number format:

rnd⁡F1,rm1=rnd⁡F1,rm1∘rnd⁡F2,rm2⇒fF1,rm1=rnd⁡F1,rm1∘fF2,rm2.\operatorname{rnd}_{F_1,\mathrm{rm}_1}=\operatorname{rnd}_{F_1,\mathrm{rm}_1}\circ\operatorname{rnd}_{F_2,\mathrm{rm}_2}\Rightarrow f_{F_1,\mathrm{rm}_1}=\operatorname{rnd}_{F_1,\mathrm{rm}_1}\circ f_{F_2,\mathrm{rm}_2}.

Thus correct double rounding enables a modular approach to building number libraries by cleanly separating rounding from arithmetic. For each real-valued function ff, it suffices to provide a high-precision implementation fF2,rm2f_{F_2,\mathrm{rm}_2} that can be safely re-rounded to the target number formats. Importantly, the rules from Figure 8 apply independently of the particular function ff unlike in prior work [54, 56]. For the intermediate rounding, the RTO rounding mode is the natural choice.

In particular, the high-precision computation can rely on existing implementations such as hardware-provided capabilities, well-tested number libraries like SoftFloat and MPFR, or custom kernels. As long as these implementations produce a correctly-rounded result that satisfies the preconditions for correct double rounding, they can be safely composed with rounding to lower-precision formats. Compared to a traditional monolithic design, this method yields a number library that is easier to maintain, requiring less code; easier to test, since only the rounding operators must be validated; and efficient, by reusing highly optimized high-precision implementations.

In § 7, we present MPFX, a prototype of this approach. We describe how it extends several high-precision implementations and evaluate its performance against existing number libraries.

Program Analyses and Transformations

The results of the previous sections—format containment and correct double rounding—operate on individual rounding operations. We now turn to programs that compose multiple correctly-rounded operations. We introduce format inference, which conservatively bounds each expression by an instance of A\mathcal{A} (§ 6.1), and use it to justify transformations that eliminate and insert roundings (§ 6.2). Together, these yield a semantics-preserving rewriting strategy for mapping numerical specifications onto a target environment’s rounded operations (§ 6.3); we apply it by hand to a case study in § 8.

Format Inference

We consider programs consisting of assignment statements whose right-hand sides are constants, variables, or applications of arithmetic operators (e.g., addition). Each operator is either correctly-rounded, fF,rmf_{F,\mathrm{rm}}, or unrounded, fR,−f_{\mathbb{R},-}, that is, it computes over the reals and does not round. For example, add⁡FP32,RNE\operatorname{add}_{\mathrm{FP32},\mathrm{RNE}} denotes correctly-rounded single-precision addition, while mul⁡R,−\operatorname{mul}_{\mathbb{R},-} denotes exact multiplication.

Format inference proceeds by analyzing each assignment statement in execution order, maintaining a mapping from variables to number formats. Numerical constants are assigned the tightest bound containing them; variables take the format they are mapped to. Correctly-rounded operations fA(p,exp⁡,b,S),rmf_{\mathcal{A}(p,\exp,b,S),\mathrm{rm}} produce values in A(p,exp⁡,b,S)\mathcal{A}(p,\exp,b,S), and unrounded operations fR,−f_{\mathbb{R},-} are assigned the “format” R\mathbb{R}.

For unrounded operations, we can often derive a tighter bound from the formats of the arguments. Negation and absolute value preserve the format of their operand, except that they negate or take the magnitude of its infinities. Addition and multiplication are as follows:

fmt⁡(add⁡R,−(e1,e2))=fmt⁡(e1)⊕fmt⁡(e2),fmt⁡(mul⁡R,−(e1,e2))=fmt⁡(e1)⊗fmt⁡(e2).\operatorname{fmt}(\operatorname{add}_{\mathbb{R},-}(e_1,e_2))=\operatorname{fmt}(e_1)\oplus\operatorname{fmt}(e_2),\qquad\operatorname{fmt}(\operatorname{mul}_{\mathbb{R},-}(e_1,e_2))=\operatorname{fmt}(e_1)\otimes\operatorname{fmt}(e_2).

Here, ⊕\oplus and ⊗\otimes are given by:

A(p1,exp⁡1,b1,S1)⊕A(p2,exp⁡2,b2,S2)⊆A(max⁡(1,⌈log⁡2(⌊b1+b22min⁡(exp⁡1,exp⁡2)⌋+1)⌉),min⁡(exp⁡1,exp⁡2),b1+b2,S⊕),A(p1,exp⁡1,b1,S1)⊗A(p2,exp⁡2,b2,S2)⊆A(p1+p2,exp⁡1+exp⁡2,b1×b2,S⊗).\begin{aligned} \mathcal{A}_{(p_1,\exp_1,b_1,S_1)} \oplus\mathcal{A}_{(p_2,\exp_2,b_2,S_2)} &\subseteq\mathcal{A}_{\left(\max\left(1,\left\lceil\log_2\left(\left\lfloor\frac{b_1+b_2}{2^{\min(\exp_1,\exp_2)}}\right\rfloor+1\right)\right\rceil\right),\min(\exp_1,\exp_2),b_1+b_2,S_{\oplus}\right)},\\ \mathcal{A}_{(p_1,\exp_1,b_1,S_1)} \otimes\mathcal{A}_{(p_2,\exp_2,b_2,S_2)} &\subseteq\mathcal{A}_{(p_1+p_2,\exp_1+\exp_2,b_1\times b_2,S_{\otimes})}. \end{aligned}

For addition, the precision is the number of binary digits needed to represent the worst-case sum, b1+b2b_1+b_2, as a multiple of 2min⁡(exp⁡1,exp⁡2)2^{\min(\exp_1,\exp_2)}. The sets S⊕S_{\oplus} and S⊗S_{\otimes} hold the special values that a sum or product can produce under IEEE 754: a NaN operand yields NaN, ∞−∞\infty-\infty and ∞×0\infty\times0 are NaN, and an infinity otherwise yields an infinity. For example, ⊗\otimes takes two values in the MX E5M2 format A(3,−16,7×213,{±∞,NaN})\mathcal{A}(3,-16,7\times2^{13},\{\pm\infty,\mathrm{NaN}\}) to A(6,−32,49×226,{±∞,NaN})\mathcal{A}(6,-32,49\times2^{26},\{\pm\infty,\mathrm{NaN}\}); § 8 traces this analysis through an entire program.

This analysis is similar to interval analysis [42], which tracks intervals [l,h][l,h] for each real-valued expression. Format inference is more precise, tracking not only the range of possible values but also their spacing, since only some values in the interval are representable.

Introducing & Eliminating Roundings

Format inference yields a single insight that enables us to insert and eliminate roundings. Since every correctly-rounded operation consists of a real-valued computation followed by a rounding fF,rm=rnd⁡F,rm∘fR,_f_{F,rm}=\operatorname{rnd}_{F,rm}\circ f_{\mathbb{R},\_}, we can apply format inference to the unrounded computation fR,_f_{\mathbb{R},\_} prior to rounding. Suppose format inference determines that the unrounded result already lies within the target format FF; formally,

fmt⁡(fR,_(e1,…,en))⊆F.\operatorname{fmt}\left(f_{\mathbb{R},\_}(e_1,\ldots,e_n)\right)\subseteq F.

In this case, every value vv produced by fR,_f_{\mathbb{R},\_} is already representable in FF, so rnd⁡F,rm(v)=v\operatorname{rnd}_{F,rm}(v)=v, assuming σ=id⁡\sigma=\operatorname{id}, and

fF,rm(e1,…,en)=fR,_(e1,…,en).f_{F,rm}(e_1,\ldots,e_n)=f_{\mathbb{R},\_}(e_1,\ldots,e_n).

This identity can be read in two directions.

Left-to-right, it justifies canonicalization: a correctly-rounded operation can be replaced by its real counterpart, since the rounding does nothing, simplifying the program. For example, consider the expression mul⁡FP32,RNE(e1,e2)\operatorname{mul}_{\mathrm{FP32},\mathrm{RNE}}(e_1,e_2), where e1e_1 and e2e_2 produce values representable in MX E5M2. In the previous subsection, format inference discovers that mul⁡R,_(e1,e2)\operatorname{mul}_{\mathbb{R},\_}(e_1,e_2) is bounded by A(6,−32,49×226,{±∞,NaN})⊆FP32\mathcal{A}(6,-32,49\times2^{26},\{\pm\infty,\mathrm{NaN}\})\subseteq\mathrm{FP32}. Therefore, the rounding to FP32 has no effect, and so the following rewrite is semantics-preserving:

mul⁡FP32,RNE(e1,e2)⟹mul⁡R,_(e1,e2).\operatorname{mul}_{\mathrm{FP32},\mathrm{RNE}}(e_1,e_2)\Longrightarrow\operatorname{mul}_{\mathbb{R},\_}(e_1,e_2).

Read right-to-left, it justifies finitization: an unrounded operation can be replaced by a correctly-rounded one, since the rounding would change nothing semantically. This transformation enables a choice of number formats and rounding modes which are available in the programming environment: real-valued computations can be replaced by equivalent roundings. Running our previous example in reverse, if we have mul⁡R,_(e1,e2)\operatorname{mul}_{\mathbb{R},\_}(e_1,e_2), where e1e_1 and e2e_2 produce values representable in MX E5M2, then we can rewrite the unrounded product into an FP32 operation available in hardware,

mul⁡R,_(e1,e2)⟹mul⁡FP32,RNE(e1,e2)\operatorname{mul}_{\mathbb{R},\_}(e_1,e_2)\Longrightarrow\operatorname{mul}_{\mathrm{FP32},\mathrm{RNE}}(e_1,e_2)

with no change in result.

The correct double rounding rules presented in § 5.2 lead to a similar bi-directional rewrite. In the canonicalization direction, we can detect correct double roundings within the program and merge them into a single correctly-rounded operation. Consider a composition rnd⁡F1,rm1(rnd⁡F2,rm2(e))\operatorname{rnd}_{F_1,rm_1}(\operatorname{rnd}_{F_2,rm_2}(e)). If we prove that it is a correct double rounding, i.e., rnd⁡F1,rm1∘rnd⁡F2,rm2=rnd⁡F1,rm1\operatorname{rnd}_{F_1,rm_1}\circ\operatorname{rnd}_{F_2,rm_2}=\operatorname{rnd}_{F_1,rm_1}, then the intermediate rounding to F2F_2 does not affect the result of the expression. We can therefore replace the composition with the single correctly-rounded operation fF1,rm1(e)f_{F_1,rm_1}(e). In the finitization direction, we can expand a correctly-rounded operation into a higher-precision computation and re-rounding, both of which are available in the programming environment.

A Rewriting Strategy

Together, format inference and the transformations of § 6.2 yield a rewriting strategy for programs of correctly-rounded operations. The strategy has three phases (Figure 9). First, format inference assigns a format to every expression. Second, canonicalization lifts the program P1P_1 to a program P2P_2 in which every rounding is essential, replacing fF,rm(e)f_{F,\mathrm{rm}}(e) with fR,_(e)f_{R,\_}(e) whenever fmt⁡(fR,_(e))⊆F\operatorname{fmt}(f_{R,\_}(e)) \subseteq F. Third, finitization lowers P2P_2 to an equivalent program P3P_3 in which every rounding is available in the programming environment, replacing each unrounded operation with a rounded one whose available format F′F' contains its inferred format. Since the inferred format need not itself be available, F′F' may be larger; we call this promotion. Unlike P1P_1 and P2P_2, P3P_3 uses only available operations and is thus fully executable.

Rewriting using canonicalization and finitization

Figure 9. Rewriting using canonicalization and finitization. All three programs, P1P_1, P2P_2, and P3P_3, are equivalent.

Format inference also guides exact decompositions, which rewrite an expression as a sum of parts, in the spirit of error-free transformations [46]. For example, splitting performs the rewrite

e⟹add⁡R,_(hi⁡k(e),lo⁡k(e)),e \Longrightarrow\operatorname{add}_{R,\_}\left(\operatorname{hi}_k(e),\operatorname{lo}_k(e)\right),

where hi⁡k(e)\operatorname{hi}_k(e) truncates ee to a multiple of 2exp⁡+k2^{\operatorname{exp}+k} and lo⁡k(e)\operatorname{lo}_k(e) is the remainder; if fmt⁡(e)=A(p,exp⁡,b)\operatorname{fmt}(e)=\mathcal{A}(p,\operatorname{exp},b) with exp⁡>−∞\operatorname{exp}>-\infty, then fmt⁡(hi⁡k(e))⊆A(∞,exp⁡+k,b)\operatorname{fmt}(\operatorname{hi}_k(e))\subseteq\mathcal{A}(\infty,\operatorname{exp}+k,b) and fmt⁡(lo⁡k(e))⊆A(∞,exp⁡,2exp⁡+k)\operatorname{fmt}(\operatorname{lo}_k(e))\subseteq\mathcal{A}(\infty,\operatorname{exp},2^{\operatorname{exp}+k}). Since the decomposition is exact, the rewrite is semantics-preserving. When fmt⁡(e)\operatorname{fmt}(e) is a fixed-point format, each part needs fewer digits than ee, so finitization can choose smaller available formats for the operations that consume them.

Since multiple lowerings are possible for P2P_2, choosing one means searching the space of possible implementations. This process is amenable to automation: both format inference and the format containment checks are straightforward and fast, and the search space of possible roundings and formats is bounded by the number of formats and operations in the programming environment; we leave automating the strategy to future work. In § 8, we manually apply this strategy to the MX dot product example from § 2 to develop optimized numerical models of the design.

Evaluation

We prototype a number library, dubbed MPFX, based on the approach outlined in § 5.3. It is a correctly-rounded, multi-precision number library implemented in C++.

To evaluate the contributions of this paper, we pose the following research questions:

RQ1 Does MPFX support a broad class of number formats and rounding modes? (§ 7.1)

RQ2 Is MPFX’s performance competitive with comparable number libraries? (§ 7.2)

RQ3 Can we use format inference and double rounding to safely implement a real-world algorithm, and can MPFX make the implementation more performant? (§ 8)

§ 7.1 describes MPFX’s implementation and expressivity; § 7.2 compares the performance of its correctly-rounded operations against SoftFloat, FloppyFloat, MPFR, and CPFloat; § 8 demonstrates how our techniques can be used to implement the MX dot product in a non-standard format, and how MPFX’s primitives improve performance.

Implementation

MPFX implements optimized rounding procedures from natively-supported floating-point and integer types to instances of A\mathcal{A} under all seven rounding modes described in § 3.2. It computes a higher-precision, round-to-odd intermediate and then re-rounds it to the target. This is correct whenever the intermediate format that Figure 8 requires is contained in the type that holds it (binary64 or binary32); RNA follows from RND-RTO-RNE, which holds for any tie-break, and RTP and RTN reduce to RAZ and RTZ by sign.

Any backend that produces this intermediate suffices; to demonstrate this generality, MPFX provides four: native floating point, the SoftFloat and FloppyFloat libraries, and custom kernels based on error-free transformations. The current implementation pads every target uniformly by two bits, so in binary6415 it supports every mode for p≤51p \le51 and exp≥−1072exp \ge-1072; a debug-build assertion checks the precision, while the exponent and bound are preconditions. The final rounding is a single software kernel for every mode: it splits the intermediate xx into s+ts + t, where ss holds the target’s retained bits, and returns ss or next(s)(s) depending on tt and the mode. On overflow it uses IEEE 754’s ω\omega, or saturates (ω(±1)=±b\omega(\pm1) = \pm b) for formats without infinities.

To ensure correctness, we test each backend exhaustively against MPFR, the de facto reference for correctly-rounded arithmetic, on every IEEE 754-style binary format of at most eight bits with a 2- to 5-bit exponent field (14 formats, each with subnormals, signed zeros, and infinities). For each format, operation (add, sub, mul, div, sqrt, fma), rounding mode, backend, and container (double or float), we evaluate every input—4,704 configurations and about 3.17 billion cases in total—and compare results bit-for-bit, including the sign of zero16. MPFR lacks RTO and supports RNA only partially, so we derive both: RTO rounds under RTZ and forces the last bit odd if inexact; RNA equals RNE except at a midpoint, where it equals RAZ. A randomized suite further checks unbounded-exponent formats of precision 2 to 8 against MPFR under five modes (all but RNA and RTO), on one million uniform inputs in [−1,1][-1, 1] per operation and mode ([0,1][0, 1] for square root).

Native Floating Point. We emulate RTO arithmetic on top of hardware floating-point arithmetic, following Boldo and Melquiond [5]. Since hardware does not natively support RTO, we emulate it in hardware by performing the operation under RTZ and then adjusting the least significant bit of the significand. We set the LSB to the logical OR of itself and the inexact flag, which can be fetched from the architectural state. After each operation, we restore the original rounding mode. This approach is slow: it must set and fetch the floating-point control register twice per operation. The resulting performance degradation has been previously documented [26, 63].

SoftFloat. We extend the SoftFloat library using its double-precision arithmetic operations. SoftFloat supports RTO, so each operation requires only setting the rounding mode (a global variable) before invoking the corresponding library function.

FloppyFloat. FloppyFloat provides similar capabilities to SoftFloat, but does not support RTO. We emulate RTO as we did for hardware floating point: performing the operations in RTZ mode, then extracting the inexact flag provided by the library.

Error-free transformations. An error-free transformation (EFT) of an operation computes the rounded result and error term(s) such that their sum is the exact real result. For example, the TwoSum algorithm [43] transforms x+yx + y into s+ts + t where ss is the nearest rounding and tt is the error term17. We can transform the result of an EFT into the RTO result. If tt is zero, then ss is the RTO result. If ss and tt have the same sign, the RTO result is ss with the least significant bit of its significand set to 1. Otherwise, we step ss one representable value toward zero, producing s′s' (the error term now has the same sign as s′s'), and set the least significant bit of the significand of s′s' to 1.

EFT algorithms [13] exist for multiplication and fused-multiply-add (FMA). For division and square-root, we cannot represent the error term exactly; however, only the sign of the error term matters, so we can disregard any lower-order errors. EFTs also extend to sums of nn numbers [58], so MPFX provides add3 and add4 operations that are rounded to odd.

This answers RQ1: in just 2,318 source lines of code, MPFX’s operations are correctly rounded for any instance of A\mathcal{A} whose Figure 8 intermediate is contained in FP64, under all seven rounding modes. Neither the arithmetic nor its round-to-odd emulation depends on the target format; only the final re-rounding does. MPFX supports only the arithmetic operations required by IEEE 754, but could extend RTO-based math libraries such as RLIBM [38] to support transcendental operations.

Performance of MPFX

We evaluate the performance of MPFX’s correctly-rounded operations against existing number libraries that also guarantee correct rounding: MPFR, SoftFloat, and FloppyFloat. We also compare against CPFloat [18], which differs from these libraries in two ways. First, its interface operates on arrays rather than scalar values; to match the others, we call it with one element per operation and discuss its array interface separately. Second, it re-rounds a round-to-nearest intermediate, so it is correctly rounded only where double rounding is innocuous: for round-to-nearest targets and the five IEEE 754 operations with p≤ph/2−1p \le p_h/2 - 1, at most 25 bits in binary64 [19, 54, 56]. Its RTP and RTZ results in Figure 10 carry no such guarantee.

Relative speedup over SoftFloat for each operation, datatype, and rounding mode

Figure 10. Relative speedup over SoftFloat for each operation, datatype, and rounding mode. The top and bottom panels show single-precision (FP32) and half-precision (FP16), with the six operations along the xx-axis. Within each operation, the bars are, left to right, MPFR, FloppyFloat (FP32 only), CPFloat, MPFX/HW, and MPFX/EFT, each as three bars for the RNE, RTP, and RTZ modes; the dashed line at y=1y = 1 is the SoftFloat baseline.

Of MPFX’s four arithmetic backends (§ 7.1), the native-floating-point and EFT backends are the fastest; we evaluate these two and denote them MPFX/HW and MPFX/EFT. The native-floating-point backend is slowed by the control-register manipulation its round-to-odd emulation requires, but its hardware arithmetic still makes it faster than MPFX’s software-library backends.

We performed all experiments on Ubuntu 26.04 LTS with an AMD EPYC 7702P CPU and 512 GB of RAM. We compiled all libraries with GCC 15.2.0 at -O2; MPFR 4.2.2 was available as a package in Ubuntu 26.04 LTS. We used SoftFloat Release 3e and the most recent version of FloppyFloat available18. We used CPFloat v0.6.0.

Methodology. We restrict to the shared features of each number library. First, we focus on IEEE 754 required arithmetic: addition, subtraction, multiplication, division, square root, and FMA. This eliminates transcendental functions (e.g., exp⁡(x)\exp(x) and sin⁡(x)\sin(x)), and algebraic operations (e.g., x3\sqrt[3]{x}), which only MPFR provides. Second, these operations are uniform-precision—that is, the arguments and result are the same number format—as only MPFR and MPFX are multi-precision. We evaluate single-precision (FP32) and half-precision (FP16), the standard formats that our baselines support and that are narrow enough for MPFX to target by re-rounding from its FP64 working precision. FloppyFloat relies on FP16 support introduced in the C++23 standard [29]. We exclude this treatment since on our machine, GCC19 compiles FP16 operations to its own software floating-point implementation, as most x86 CPUs lack hardware half-precision arithmetic. Last, we compare over three rounding modes: RNE, RTP, and RTZ.

For each operation and rounding mode, we sampled 10 million inputs from the uniform distribution on [−1,1][-1,1] for each argument. We then measured the execution time of evaluating over all the inputs in a tight loop for each of the number libraries, averaging over 30 iterations to reduce variance. Finally, we computed the relative speedup over the corresponding SoftFloat implementation.

We take SoftFloat as the baseline because it is the standard, portable software implementation of correctly-rounded IEEE 754 arithmetic, with reasonable performance.

Results. Figure 10 shows the results of the comparison. Being arbitrary-precision, MPFR is much slower than the other libraries, since managing variable-width significands adds overhead to every operation. FloppyFloat is faster than SoftFloat for single-precision operations (FP32), especially for nearest rounding, since it uses floating-point rather than integer operations to model IEEE 754 arithmetic. Our results resemble those reported by Zurstraßen et al. [64], but FloppyFloat is slower than SoftFloat for certain operators under RTP and RTZ. We exclude FloppyFloat from the half-precision comparison for the reason given in the methodology. With one element per call, CPFloat is slower than MPFX on every operation, by 1.6×1.6 \times to 4.7×4.7 \times. Called on arrays of 10 million inputs, it is instead 4.6×4.6 \times to 12.2×12.2 \times faster than MPFX, because it derives the target format’s parameters (subnormal thresholds, overflow bound, significand masks) once per call rather than once per element. The difference reflects API granularity, not the cost of rounding; a batched MPFX interface could amortize the same work.

In answer to RQ2, MPFX is competitive with SoftFloat despite being a compact library that is not highly optimized; across the operations, datatypes, and rounding modes we measure, the faster of its native-floating-point and EFT implementations runs between 0.44×0.44 \times and 1.62×1.62 \times as fast as SoftFloat’s, and up to 13.5×13.5 \times faster than MPFR. The slowest of these is MPFX/EFT on FP32 division under RTP, and the fastest is MPFX/EFT on FP16 FMA under RTZ. Because MPFX’s native floating-point arithmetic (MPFX/HW) relies on modifying architectural state, we expect the results for that treatment to vary the most across different hardware architectures and generations. This comparison uses only formats the baselines support; § 8 covers a non-standard one.

Case Study: MX Dot Product

In § 2, we motivated the need to implement the MX dot product algorithm using existing software operations; in § 6, we introduced a strategy for mapping unavailable operations onto available arithmetic. We now apply that strategy to construct a faithful numerical model of the MX dot product.

The program in Figure 2 (left) is fully-specified: every input yields a unique result. We assume each block’s 32 elements are finite values of the 8-bit MX E5M2 format, i.e., A(3,−16,57344)\mathcal{A}(3,-16,57344); following the standard [53], each scale factor is a power of two in [2−127,2127][2^{-127},2^{127}]. The local dot product for each block pair (lines 6–9) is computed exactly; accumulation across pairs (line 10) is rounded to FP32 under RNE after each step.

One might ask whether faithfully modeling the specification is necessary at all—could a naive implementation, running the entire dot product uniformly in FP32, suffice? Figure 11 answers this question: we ran this naive implementation on a million randomly sampled MX block pairs (with C=0C = 0) and plotted each disagreement as a point, using the encodings of blocks AA and BB as coordinates20. The implementation produces incorrect results on roughly 5.2% of the inputs. The absence of error in the upper right corner of the plot corresponds to overflow and the dense band in the lower left corresponds to underflow; otherwise, the errors are distributed uniformly across the input space. FP32 is simply insufficient to faithfully model the specification, motivating the more careful approach of § 6. Next, we show how to properly map the algorithm onto SoftFloat’s IEEE 754 operations, then highlight how MPFX’s richer primitives yield a much faster implementation.

Mismatches between the specification in Figure 2 (left) and a naive implementation that runs the entire dot product uniformly in FP32.

Figure 11. Mismatches between the specification in Figure 2 (left) and a naive implementation that runs the entire dot product uniformly in FP32.

Mapping to SoftFloat

At first glance, it seems unclear how to map each operation of the program to rounded operations supported by SoftFloat (or native hardware). In addition, we do not know what number formats can safely store any intermediate computations. As an initial step, we apply format inference to bound each expression by a number format. Figure 12 shows the result.

The specification of Figure 2 annotated in blue with the format inferred for each intermediate.

Figure 12. The specification of Figure 2 (left), annotated in blue with the format inferred for each intermediate: operand formats combine via ⊗\otimes (multiplication) or ⊕\oplus (accumulation). The inner loop is unrolled for the analysis, so line 8’s ⊕\oplus spans all 32 products. Line 10’s FP32 format is set by the specification, not inferred.

1  def accurate_mx_dot(A, B):
2      C = 0
3      for (X_i^A, P_i^A), (X_i^B, P_i^B) in zip(A, B):
4          X = mulR_◻(X_i^A, X_i^B)    A(1, −127, 2^127) ⊗ A(1, −127, 2^127) = A(2, −254, 2^254)
5          V = 0
6          for P^A_{i,j}, P^B_{i,j} in zip(P^A_i, P^B_i):
7              t_1 = mulR_◻(P^A_{i,j}, P^B_{i,j})    A(3, −16, 7 × 2^13) ⊗ A(3, −16, 7 × 2^13) = A(6, −32, 49 × 2^26)
8              V = addR_◻(V, t_1)    ⨁_{j=1}^{32} A(6, −32, 49 × 2^26) = A(69, −32, 1568 × 2^26)
9              t_2 = mulR_◻(X, V)    A(2, −254, 2^254) ⊗ A(69, −32, 1568 × 2^26) = A(71, −286, 1568 × 2^280)
10             C = addFP32,RNE(C, t_2) → A(24, −149, (2^24 − 1) × 2^104) (FP32)
11     return C

Each scale factor lies in A(1,−127,2127)\mathcal{A}(1,-127,2^{127}) and each block element in the finite values of E5M2, A(3,−16,7×213)\mathcal{A}(3,-16,7 \times2^{13}); format inference propagates these bounds through the program to derive rest21. The accumulator VV is the interesting case: its precision reaches p=69p = 69, the precision of its largest value 1568×226=c×2−321568 \times2^{26} = c \times2^{-32} (where 1568=32×491568 = 32 \times49) under the quantum 2−322^{-32}—already beyond double precision (p=53p = 53). After scaling by XX, the local dot product needs A(71,−286,1568×2280)\mathcal{A}(71, -286, 1568 \times2^{280}).

Recall that the SoftFloat library only supports IEEE 754 floating-point number formats—for example, it has no (unrounded) multiplication implementation (line 7) with the signature

A(3,−16,7×213)×A(3,−16,7×213)→A(6,−32,49×226).\mathcal{A}(3, -16, 7 \times2^{13}) \times\mathcal{A}(3, -16, 7 \times2^{13}) \to\mathcal{A}(6, -32, 49 \times2^{26}).

We can overcome this issue by finitization (§ 6.3), promoting to a supported format that contains the inferred one. For the multiplication, both the input and resulting number formats satisfy F⊆FP32F \subseteq\mathrm{FP32}, so we can promote both input and output types to FP32:

mul⁡FP32,RNE(rnd⁡FP32,RNE(Pi,jA),rnd⁡FP32,RNE(Pi,jB)).\operatorname{mul}_{\mathrm{FP32},\mathrm{RNE}}\left(\operatorname{rnd}_{\mathrm{FP32},\mathrm{RNE}}(P^{A}_{i,j}),\operatorname{rnd}_{\mathrm{FP32},\mathrm{RNE}}(P^{B}_{i,j})\right).

Here, rnd⁡FP32,RNE\operatorname{rnd}_{\mathrm{FP32},\mathrm{RNE}} coerces Pi,jAP^{A}_{i,j} and Pi,jBP^{B}_{i,j} into a single-precision floating-point number. The conversion is lossless, so any rounding mode suffices; we choose RNE. Now, the multiplication is a uniform, single-precision, floating-point multiplication which SoftFloat—and native hardware—provide.

For the rest of the program, we continue promoting the number formats produced by format inference. Whenever the resulting number format of an operation is larger than the arguments, we promote the arguments to the larger type. The result of the process is shown in Figure 13.

Our implementation of the dot product using SoftFloat or hardware-supported floating-point operations

Figure 13. Our implementation of the dot product using SoftFloat or hardware-supported floating-point operations. This program is semantically equivalent to the original specification.

1  def our_mx_dot_softfloat(A, B):
2      C = 0
3      for (X^A_i, P^A_i), (X^B_i, P^B_i) in zip(A, B):
4          X = mulFP64,RNE (rndFP64,RNE (X^A_i), rndFP64,RNE (X^B_i))
5          V = 0
6          for P^A_{i,j}, P^B_{i,j} in zip(P^A_i, P^B_i):
7              t = mulFP32,RNE (rndFP32,RNE (P^A_{i,j}), rndFP32,RNE (P^B_{i,j}))
8              V = addFP128,RNE (V, rndFP128,RNE (t))
9          t_2 = mulFP128,RNE (X, V)
10         t_3 = addFP128,RTO (t_2, rndFP128,RNE (C))
11         C = rndFP32,RNE (t_3)
12     return C

The program uses a mix of number formats, but every operation is uniform-precision, with added casts where necessary. Some operations can be supported in hardware, such as the double-precision multiplication of the scale factors, and the single-precision multiplication of the elements. To support the largest number format, A(71,−286,1568×2280)\mathcal{A}(71, -286, 1568 \times2^{280}), we use FP128, or quad-precision floating-point, from SoftFloat, which is a very large number format whose operations are slower than those of smaller formats. We implement the final rounded addition using a correct double rounding, first rounding to FP128, and then re-rounding to FP32 to update CC.

Our approach is essential for implementing the dot product faithfully. Format inference identifies number formats for every expression, and helps rewrite the program to only use supported operations by promoting number formats where necessary. The result of this process is a program that matches the intended numerical behavior without requiring the developer to create bespoke implementations of arithmetic operations. However, a limitation with a library like SoftFloat is that it provides only a small set of primitives, so some operations must use larger-than-necessary types, which can incur a performance penalty.

Going Faster with MPFX. Compared to SoftFloat, MPFX offers a very large set of primitives, composed of different arithmetic methods and re-rounding to a variety of number formats. For users, this flexibility allows them to choose the arithmetic method and target format, making it easier to implement correctly-rounded operations and to express the number format they actually want. Does this flexibility lead to a more performant dot product implementation?

We target the slowest part of the SoftFloat design: the accumulation in FP128. Recall that format inference derives A(69,−32,1568×226)\mathcal{A}(69,-32,1568 \times2^{26}) as the number format for VV. Rather than selecting FP128, we choose a fixed-point format, A(∞,−32,295−2−32)\mathcal{A}(\infty,-32,2^{95}-2^{-32}), which can be encoded in a 128-bit integer with an implicit scaling factor of 2−322^{-32} (most C/C++ compilers support 128-bit integers through non-standard extensions22). The accumulation can now be performed using standard integer arithmetic, which is much faster than SoftFloat’s addition operation.

Unfortunately, the scaling factor complicates our plan. Post-scaling, the local dot product is representable in A(71,−286,1568×2280)\mathcal{A}(71,-286,1568 \times2^{280}); a valid fixed-point format for this value would need to be backed by a 1024-bit integer, at minimum; the scale factor, XX, would require a 512-bit integer. The workaround is to split VV (§ 6.3) into Vhi+VloV_{hi}+V_{lo} with k=40k=40: since only 69 digits of the 128-bit integer backing VV are significant, each part fits a 64-bit integer, VhiV_{hi} with scale factor 2−32+402^{-32+40} and VloV_{lo} with scale factor 2−322^{-32}.

This decomposition allows us to rewrite (X×RV)+FP32,RNEC(X \times_{\mathrm{R}} V)+_{\mathrm{FP32,RNE}} C into a three-argument addition:

add3⁡FP32,RNE(mul⁡R,_(X,Vhi),mul⁡R,_(X,Vlo),C)\operatorname{add3}_{\mathrm{FP32,RNE}}\bigl(\operatorname{mul}_{\mathrm{R},\_}(X,V_{hi}),\operatorname{mul}_{\mathrm{R},\_}(X,V_{lo}),C\bigr)

The remaining question is how to implement the two new factors X×RVhiX \times_{\mathrm{R}} V_{hi} and X×RVloX \times_{\mathrm{R}} V_{lo}. If we split with 40 digits, we can infer that VhiV_{hi} must be contained in A(29,8,1568×226)\mathcal{A}(29,8,1568 \times2^{26}) and VloV_{lo} is contained in A(40,−32,28)\mathcal{A}(40,-32,2^8). Then X×RVhiX \times_{\mathrm{R}} V_{hi} and X×RVloX \times_{\mathrm{R}} V_{lo} are representable in A(31,−246,1568×2280)\mathcal{A}(31,-246,1568 \times2^{280}) and A(42,−286,2262)\mathcal{A}(42,-286,2^{262}), respectively. Crucially, all of these number formats are contained in a double-precision floating-point format. Therefore, we can convert VhiV_{hi} and VloV_{lo} to double-precision floating-point values and perform the multiplication using double-precision arithmetic uniformly.

def our_mx_dot_mpfx(A, B):
    C = 0
    for (X_i^A, P_i,j^A), (X_i^B, P_i,j^B) in zip(A, B):
        X = mul_FP64,RNE(rnd_FP64,RNE(X_i^A), rnd_FP64,RNE(X_i^B))
        V = 0
        for P_i,j^A, P_i,j^B in zip(P_i,j^A, P_i,j^B):
            t = mul_FP32,RNE(rnd_FP32,RNE(P_i,j^A), rnd_FP32,RNE(P_i,j^B))
            V = add_{\mathcal{A}(\infty,-32,2^95-2^-32),RNE}(V, rnd_{\mathcal{A}(\infty,-32,2^95-2^-32),RNE}(t))
        V_hi, V_lo = split(V, 40)
        t_2 = mul_FP64,RNE(X, rnd_FP64,RNE(V_hi))
        t_3 = mul_FP64,RNE(X, rnd_FP64,RNE(V_lo))
        C = add_FP32,RNE(t_2, t_3, C)
    return C

Fig. 14. Our implementation of the dot product using MPFX or hardware-supported floating-point operations. This program is semantically equivalent to the original specification.

The full implementation is shown in Figure 14 using a mix of native integer and floating-point operations and MPFX’s primitives. By replacing FP128 accumulation with 128-bit integer arithmetic and using native FP64 for the remaining multiplications, the implementation avoids SoftFloat’s most expensive operations entirely. The split and three-argument adder from MPFX ensure the final rounding is still correct.

Comparison. We repeated the same approach, choosing two additional combinations of number formats for the element vectors PiAP_i^A and PiBP_i^B: E5M2×\timesE4M3, and E4M3×\timesE4M3. For each configuration, we developed a SoftFloat implementation and an MPFX implementation using the previously-described techniques. We sampled 100,000 input vectors of length 4096 from a standard normal distribution and applied block quantization [53] to each vector to form MX blocks. We then measured the run time of each program on these MX blocks and computed the relative speedup of the MPFX implementation over the SoftFloat implementation.

Table 3 shows our results. For the worked example, labeled E5M2×\timesE5M2 in the table, we achieve a 9.99×\times speedup over our SoftFloat implementation. For E5M2 ×\times E4M3, the MPFX implementation uses 64-bit integers instead of 128-bit integers, but the overall approach is similar, including splitting the accumulator and the three-argument adder; we achieve a greater speedup of 13.26×\times. For E4M3 ×\times E4M3, format inference proves that we can use double-precision arithmetic uniformly throughout the inner dot product, including scaling. This observation applies to both the SoftFloat and MPFX implementation. The speedup for this configuration is smaller: the only difference between the programs is the implementation of the final adder.

FormatsE5M2 ×\times E5M2E5M2 ×\times E4M3E4M3 ×\times E4M3
Speedup9.99×\times13.26×\times1.40×\times

Table 3. Relative speedup of MPFX’s implementations compared to SoftFloat’s implementations for three different combinations of number formats for the element vectors.

Discussion. In this case study, we show how the techniques from § 6 can be applied to a real-world algorithm using existing library operations. Without these techniques, it would be difficult to faithfully implement the algorithm over a non-standard format, answering the first part of RQ3. Further, MPFX’s support for non-standard formats and multi-precision operations allows us to exploit cheaper arithmetic, which is inexpressible in SoftFloat, answering the second part of our research question. Underlying both is the abstract number format A\mathcal{A}: format inference uses it to determine what each expression requires, and MPFX uses it to round to exactly those formats.

Limitations and Future Work

We would like to support additional number formats. Posit numbers [23] use a dynamic rather than a fixed precision that varies with the magnitude of the representable value. Strictly positive formats, such as the MX E8M0 format [53] used for block scales, are not directly representable in A\mathcal{A}. The most recent draft of the IEEE P3109 standard [27] introduces unsigned floating-point numbers; we believe setting b−=0b^{-}=0 would suffice to support them, but have not yet verified this.

Our formats have a single zero. IEEE 754 distinguishes +0 and −0; modeling signed zero would let our rules account for its sign. Subnormals pose a challenge: floating-point implementations often allow disabling subnormalization, flushing subnormal values to zero. We would like to investigate how flushing affects format containment and correct double rounding.

Format inference (§ 6.1) covers straight-line programs; loops with a static bound can be unrolled, as in our case study (§ 8). Supporting loops with dynamic bounds requires, as in interval analysis, a widening operator, since formats have infinite ascending chains under containment; the resulting formats may be impractically wide.

Finally, we plan to improve MPFX. Since it supports single-precision containers, we can integrate the RLIBM [38] math library to support transcendental functions: its operations are rounded to odd and can be re-rounded to single precision. We also plan to adopt CFloat’s optimized rounding algorithms [18], which target exactly MPFX’s rounding primitives.

Related Work

Our work focuses on number libraries, floating-point formalizations, double rounding, and rounding to odd. We discuss related work in each of these areas.

Number libraries. MPFX is most similar to CPFloat [18]; CPFloat uses hardware floating-point arithmetic for higher precision computation and then optimized rounding kernels to round to the target format. In particular, they support IEEE 754-like number formats: A(p,emin⁡−p+1,(2−21−p)×2emax⁡)\mathcal{A}(p, e_{\min}-p+1, (2-2^{1-p})\times2^{e_{\max}}), and also offer stochastic rounding, which MPFX lacks. The focus of the work concerns rounding algorithms: for basic arithmetic operations, they appeal to strong assumptions for correct rounding found in prior work [54, 56]. MXSim [28] builds on CPFloat to simulate MX-like block floating-point formats with customizable element, scale, and accumulator formats, and requires the same assumptions for correct rounding. FloatX [20] employs a similar technique, but stores results in a custom container type. They note that their double roundings may not be correctly rounded.

Most number libraries do not follow the double rounding architecture of MPFX. The SoftFloat library [25] emulates IEEE 754 floating-point arithmetic using only machine integer operations, providing highly optimized implementations of basic arithmetic operations. FloppyFloat [64] supports a subset of SoftFloat’s operations. The library instead computes the rounded result under RNE using hardware floating-point arithmetic, and fixes up the result for the desired rounding mode. The SIPE library [36] represents numbers as a pair of integers (significand and exponent) and simulates efficient, low-precision, floating-point arithmetic; underflow and overflow are not modeled. Like SoftFloat and FloppyFloat, the operations provided by SIPE are uniform-precision: the precision of the arguments and result is the same. The Universal library [47, 48] is an extensive compendium of fixed-point, floating-point, posit, and logarithmic formats, among others. Supporting them with the traditional approach is, as the developers note, a “major undertaking with complex validation requirements” [47].

Finally, arbitrary-precision number libraries allow theoretically unbounded precision. Because of their unbounded nature, their implementations must allocate memory to represent numbers. The state-of-the-art arbitrary-precision floating-point library is MPFR [21], which provides correctly-rounded operations for an array of arithmetic, algebraic, and transcendental functions. Arbitrary-precision integer libraries, such as GNU MP [22], are arguably number libraries too.

Floating-point formalization. Generic formalizations of floating-point arithmetic predate our work. The PFF library [16] formalizes floating-point numbers in Coq [61] over an arbitrary radix as (significand, exponent) pairs whose exponent is bounded below but unbounded above, deferring overflow to a separate, final step. Harrison [24] gives a comparable radix-two theory in HOL Light that carefully separates a number’s real value from its bit-string encoding; like PFF, it rounds into a format unbounded above and detects overflow afterward, mirroring how we round into F^\widehat{F} before applying the bound bb (§ 3.2). Both presentations target error analysis and the verification of arithmetic and hardware rather than format containment or double rounding, and neither treats fixed-point as a first-class format. Jacobsen et al. [31] extend Harrison’s theory to an arbitrary radix and glue fixed- and floating-point numbers together to model IEEE 754 normals and subnormals; our format instead unifies them as one family A(p,exp,b)\mathcal{A}(p, \mathit{exp}, b), with fixed-point arising when p=∞p=\infty.

The Flocq library [7] is a more recent and comprehensive Coq formalization [61] whose generic format—parameterized by a radix and a canonical-exponent function—likewise covers fixed- and floating-point formats with optional subnormalization. Our abstract number format corresponds to this generic format with an added bound and special values (§ 4.2); we use its particular parameterization to decide format containment and correct double rounding. More recently, Chang et al. [10] give a Lean formalization of the draft IEEE P3109 standard for low-precision machine-learning formats. Like ours, their work is mechanized in Lean and must grapple with the degeneracies of one-bit-precision formats; in contrast, it aims to faithfully specify a single standard and its algorithms rather than reason about format containment or double rounding across formats.

Double rounding. The seminal work on correct double rounding is by Boldo and Melquiond [5]. They prove that round to odd (RTO) and p+2p + 2 digits of precision ensures correct rounding to pp digits under the RNE mode. Like theirs, our rules place conditions on the formats alone, so they apply to any real number and thus any function; § 5.2 credits the prior work behind each rule. Figueroa [19] gives precision conditions under which RNE double rounding is innocuous for each basic arithmetic operation, roughly 2p2p digits for a pp-digit target; Roux [54] formalizes these conditions in Coq, including underflow and radices other than two, and Rump [56] extends them to directed rounding and special values such as signed zero. Martin-Dorel et al. [41] study the converse problem: how unavoidable double rounding affects algorithms such as 2Sum.

Round to odd. Boldo and Melquiond [6] present a few formally-verified applications of the round to odd rounding mode including a fused-multiply-add (FMA) algorithm and correctly-rounded summation. The RLIBM math library [38, 39] consists of automatically-generated polynomial approximations of transcendental functions that are rounded to odd, allowing correct double rounding to single precision under any of the standard rounding modes. Our work applies similar techniques to number libraries, an approach mentioned but not explored in Flegar et al. [20]. We were particularly inspired by RLIBM’s philosophy of focusing on representable values rather than real numbers in our formalism and applications.

Error analyzers. A separate line of work builds tools that automatically bound the round-off error of floating-point computations. We do not compute error bounds, but these tools share our reasoning about when an operation is exact. VCFloat [2, 51] proves sound round-off error bounds in a proof assistant and recognizes exact operations, such as Sterbenz subtraction [43] and multiplication by powers of two, to tighten them. Gappa [15] certifies bounds over both fixed- and floating-point rounded operators, detecting exact operations with the same two properties our format A(p,exp,b)\mathcal{A}(p, exp, b) unifies: that a value is an integer multiple of a quantum, and that its significand fits in pp bits. These tools exploit exactness to tighten error bounds; we exploit it through format containment to drop or insert roundings while preserving correct rounding. Type systems can also bound roundoff error: Numerical Fuzz [33] targets forward error, and Bean [34], backward error.

Rewriting numerical programs. Like our rewriting strategy (§ 6), verified compilers transform numerical programs to map operations onto those available in a programming environment. RealCake [3] applies fast-math optimizations in CakeML, proving the optimized result stays within a user-specified error bound of the program’s real-valued semantics rather than preserving its exact value. Our transformations instead keep the correctly-rounded result exactly.

Precision tuning. Mixed-precision tuning also assigns number formats to a program’s operations, but toward a different end. Tools such as Precimonious [55], FPTuner [12], Daisy [14], and POPiX [4] search for low-precision assignments that minimize cost while keeping the result within an accuracy bound, exploring programs with different semantics; Ischye and Lohar [30] give a recent overview. Our rewriting strategy (§ 6), by contrast, applies only semantics-preserving rewrites, choosing formats that preserve the program’s exact result rather than trading accuracy for cost. The two are complementary: a precision tuner could choose a program’s roundings, and our format containment could then check whether that program maps onto the available primitives, or decide when two candidate programs are equivalent to prune the search.

Conclusion

We characterize which pairings of rounding modes support correct double rounding, with easily checkable sufficient conditions on the formats, enabled by the abstract number format A\mathcal{A}—which parameterizes fixed- and floating-point formats—and an efficient, complete check for format containment. Our work complements prior results that apply to specific operations [54, 56] or pairs of rounding modes [5]. Format containment allows us to reason about correct double rounding at two levels: for individual operations, it determines when double rounding preserves correctness; for whole programs, it drives a rewriting strategy that maps unsupported operations onto available library or hardware primitives. MPFX demonstrates that a modular number library based on double rounding can be competitive with established libraries like MPFR and SoftFloat, despite supporting a far broader class of number formats. A case study on a real-world machine learning algorithm shows that targeting MPFX’s primitives yields faster implementations. As hardware number formats continue to diversify, correct double rounding offers a principled and scalable path to supporting them in software.

Proofs

This appendix contains proofs for the format containment rules (§ 5.1), the correct double rounding rules (§ 5.2), and the format inference rules (§ 6.1). All of these proofs are mechanized in Lean; Table 4 maps rules and lemmas to their Lean theorems (in namespace Mpfx).

ResultLean theorem
A\mathcal{A}-Contains-Prec, A\mathcal{A}-Contains-SubFormat.containsPrec, Format.containsSub
Lemma 5.1Format.subset_iff_contains
Lemma 5.2FiniteFormat.numDigits (definition)
Lemma 5.3FiniteFormat.numDigits_extend
Lemma 5.4IsOdd.transfer_of_subset
RND-RTZ-RTZ, RND-RAZ-RAZroundsRTZ_RTZ_inBound, roundsRAZ_RAZ_inBound
RND-RTO-RTOroundsRTO_RTO_inBound
RND-RTO-RTZ, RND-RTO-RAZroundsRTO_RTZ_inBound, roundsRTO_RAZ_inBound
RND-RTO-RNE (any tie-break)roundsRTO_RN_inBound
(both overflow)roundsX_Y_noOverflow (six theorems)
RND-Doublernd_double; per rule, rndX_Y_of_bound
Counterexamples (Table 2)Cex.no_rndX_Y (ten theorems)
⊗\otimes and ⊕\oplus rulesFormat.mul_subset, Format.add_subset
Negation and absolute valueFormat.neg_subset, Format.abs_subset

Table 4. Lean theorems for the principal rules and lemmas of Sections 5 and 6.

Format Containment

We prove soundness of the two inference rules that derive A(p1,exp1,b1,S1)⊆A(p2,exp2,b2,S2)\mathcal{A}(p_1, exp_1, b_1, S_1) \subseteq\mathcal{A}(p_2, exp_2, b_2, S_2), and then their completeness (Lemma 5.1). Special values are not numbers, so this containment holds exactly when S1⊆S2S_1 \subseteq S_2 and the numerical values are contained; below we prove the latter, writing A(p,exp,b)\mathcal{A}(p, exp, b) for the numerical values. A\mathcal{A}-Contains-Prec handles the general case, while A\mathcal{A}-Contains-Sub handles degenerate floating-point formats (and bounded fixed-point formats) where A\mathcal{A}-Contains-Prec does not apply.

Proof of A\mathcal{A}-Contains-Prec. Let x∈A(p1,exp1,b1)x \in\mathcal{A}(p_1, exp_1, b_1). The precision and magnitude constraints transfer to A(p2,exp2,b2)\mathcal{A}(p_2, exp_2, b_2) directly: xx has precision at most p1≤p2p_1 \le p_2, and ∣x∣≤b1≤b2\lvert x\rvert\le b_1 \le b_2. It remains to check the quantum constraint, on which we case split.

If exp2=−∞exp_2 = -\infty, then A(p2,−∞,b2)\mathcal{A}(p_2, -\infty, b_2) imposes no quantum constraint, and the two facts above give x∈A(p2,−∞,b2)x \in\mathcal{A}(p_2, -\infty, b_2). Otherwise exp2>−∞exp_2 > -\infty, and since exp1≥exp2exp_1 \ge exp_2 we have exp1>−∞exp_1 > -\infty as well. Write x=(−1)s×c×2exp1x = (-1)^s \times c \times2^{exp_1} where cc has precision at most p1≤p2p_1 \le p_2. Since exp1≥exp2exp_1 \ge exp_2, we can rewrite

x=(−1)s×(c×2exp1−exp2)×2exp2,x = (-1)^s \times\left(c \times2^{exp_1-exp_2}\right) \times2^{exp_2},

so xx is an integer multiple of 2exp22^{exp_2}, satisfying the quantum constraint. Therefore, x∈A(p2,exp2,∞)x \in\mathcal{A}(p_2, exp_2, \infty).

Proof of A\mathcal{A}-Contains-Sub. Let x∈A(p1,exp1,b1)x \in\mathcal{A}(p_1, exp_1, b_1). Since xx has quantum at least 2exp12^{exp_1}, write x=(−1)s×c×2exp1x = (-1)^s \times c \times2^{exp_1} for some c≥0c \ge0. From ∣x∣≤b1≤2exp1+p2\lvert x\rvert\le b_1 \le2^{exp_1+p_2} we obtain c×2exp1=∣x∣≤2exp1+p2c \times2^{exp_1} = \lvert x\rvert\le2^{exp_1+p_2}, so c≤2p2c \le2^{p_2}. An integer of magnitude at most 2p22^{p_2} has a significand of at most p2p_2 digits, so xx has precision at most p2p_2—even when p1>p2p_1 > p_2. Moreover, since exp2≤exp1exp_2 \le exp_1, the value

x=(−1)s×(c×2exp1−exp2)×2exp2x = (-1)^s \times\left(c \times2^{exp_1-exp_2}\right) \times2^{exp_2}

is an integer multiple of 2exp⁡22^{\operatorname{exp}_2}, so it satisfies the quantum constraint. Finally, ∣x∣≤b1≤b2|x| \le b_1 \le b_2, and we conclude x∈A(p2,exp⁡2,b2)x \in\mathcal{A}(p_2,\operatorname{exp}_2,b_2). □

Proof of Lemma 5.1. We need to prove that if F1⊆F2F_1 \subseteq F_2, then A\mathcal{A}-Contains-Prec or A\mathcal{A}-Contains-Sub applies. Suppose F1⊆F2F_1 \subseteq F_2, and let x0≠0x_0 \ne0 be a value of F1F_1, which exists since F1F_1 is non-trivial.

Bound. If b2=∞b_2 = \infty, then b1≤b2b_1 \le b_2. Otherwise, if b1b_1 is finite, then b1∈F1b_1 \in F_1 since b1b_1 is representable in A(p1,exp⁡1,∞)\mathcal{A}(p_1,\operatorname{exp}_1,\infty), so b1∈F2b_1 \in F_2 and b1≤b2b_1 \le b_2. If b1=∞b_1 = \infty, then F1F_1 contains 2k2^k for every k≥exp⁡1k \ge\operatorname{exp}_1, including some 2k>b22^k > b_2, which is not in F2F_2; a contradiction.

Exponent. If exp⁡2=−∞\operatorname{exp}_2 = -\infty, then exp⁡1≥exp⁡2\operatorname{exp}_1 \ge\operatorname{exp}_2. Otherwise, if exp⁡1\operatorname{exp}_1 is finite, then 2exp⁡1≤∣x0∣≤b12^{\operatorname{exp}_1} \le|x_0| \le b_1, so 2exp⁡1∈F1⊆F22^{\operatorname{exp}_1} \in F_1 \subseteq F_2; since every value of F2F_2 is a multiple of 2exp⁡22^{\operatorname{exp}_2}, exp⁡1≥exp⁡2\operatorname{exp}_1 \ge\operatorname{exp}_2. If exp⁡1=−∞\operatorname{exp}_1 = -\infty, then F1F_1 contains 2k2^k for some k<exp⁡2k < \operatorname{exp}_2 with 2k≤∣x0∣2^k \le|x_0|, which is not a multiple of 2exp⁡22^{\operatorname{exp}_2}; a contradiction.

Precision. If p1≤p2p_1 \le p_2, then A\mathcal{A}-Contains-Prec applies. Otherwise p2<p1p_2 < p_1, so p2p_2 is finite. For any kk, the value wk=(2p2+1)×2kw_k = (2^{p_2} + 1) \times2^k has an odd significand of p2+1≤p1p_2 + 1 \le p_1 digits, so wk∉F2w_k \notin F_2, and hence wk∉F1w_k \notin F_1: either k<exp⁡1k < \operatorname{exp}_1 or wk>b1w_k > b_1. If exp⁡1=−∞\operatorname{exp}_1 = -\infty, some wk≤∣x0∣≤b1w_k \le|x_0| \le b_1 would lie in F1F_1; so exp⁡1\operatorname{exp}_1 is finite. Finally, suppose b1>2exp⁡1+p2b_1 > 2^{\operatorname{exp}_1+p_2}. If b1=∞b_1 = \infty, then wexp⁡1∈F1w_{\operatorname{exp}_1} \in F_1 directly; otherwise b1=m×2exp⁡1b_1 = m \times2^{\operatorname{exp}_1} for an integer m>2p2m > 2^{p_2}, so wexp⁡1≤b1w_{\operatorname{exp}_1} \le b_1 and again wexp⁡1∈F1w_{\operatorname{exp}_1} \in F_1. Either way we have a contradiction, so b1≤2exp⁡1+p2b_1 \le2^{\operatorname{exp}_1+p_2}. With the bound and exponent conditions, A\mathcal{A}-Contains-Sub applies. □

Both restrictions on F1F_1 are necessary. Without a representable bound, the formats A(∞,0,3/2)\mathcal{A}(\infty,0,3/2) and A(∞,0,1)\mathcal{A}(\infty,0,1) are both {0,±1}\{0,\pm1\}, yet neither rule applies, since 3/2>13/2 > 1. Without non-triviality, A(∞,0,0)=A(∞,1,0)={0}\mathcal{A}(\infty,0,0) = \mathcal{A}(\infty,1,0) = \{0\}, yet neither rule applies, since 0<10 < 1.

Correct Double Rounding

We prove soundness of the rules in Figure 8. The first six rules establish ⟨F1,rm1⟩▹⟨F2,rm2⟩\langle F_1,rm_1\rangle\mathrel{\triangleright} \langle F_2,rm_2\rangle for rounding modes rm1,rm2rm_1,rm_2 among RNE, RTZ, RAZ, and RTO: we first show that rounding a real number through F2F_2 matches rounding it directly to F1F_1 when neither overflows, and then that the two overflow together. RND-DOUBLE then extends the result to special values. Let x∈Rx \in\mathbb{R} be a real number. We first show that the number of digits that rnd⁡A(p1,exp⁡1,b1),rm(x)\operatorname{rnd}_{\mathcal{A}(p_1,\operatorname{exp}_1,b_1),rm}(x) rounds to is a function of p1p_1, exp⁡1\operatorname{exp}_1, and xx:

Proof of Lemma 5.2. If x=0x = 0, then the number of digits rounded to is 0, so assume x≠0x \ne0 and let e=⌊log⁡2∣x∣⌋e = \lfloor\log_2 |x| \rfloor denote the exponent of xx. We compute exp⁡′\operatorname{exp}', the position of the least significant digit that rnd⁡A(p,exp⁡,b),rm(x)\operatorname{rnd}_{\mathcal{A}(p,\operatorname{exp},b),rm}(x) retains, by case analysis on pp and exp⁡\operatorname{exp}:

  • If p=∞p = \infty and exp⁡>−∞\operatorname{exp} > -\infty, then A(p,exp⁡,b)\mathcal{A}(p,\operatorname{exp},b) is a fixed-point format with quantum 2exp⁡2^{\operatorname{exp}}, so exp⁡′=exp⁡\operatorname{exp}' = \operatorname{exp}.

  • If p<∞p < \infty and exp⁡=−∞\operatorname{exp} = -\infty, then A(p,exp⁡,b)\mathcal{A}(p,\operatorname{exp},b) is a floating-point format with precision pp, so exp⁡′=e−p+1\operatorname{exp}' = e - p + 1.

  • If p<∞p < \infty and exp⁡>−∞\operatorname{exp} > -\infty, then A(p,exp⁡,b)\mathcal{A}(p,\operatorname{exp},b) is a floating-point format with precision pp and minimum quantum 2exp⁡2^{\operatorname{exp}}, so exp⁡′=max⁡(e−p+1,exp⁡)\operatorname{exp}' = \max(e - p + 1,\operatorname{exp}).

In every case exp⁡′\operatorname{exp}' depends only on pp, exp⁡\operatorname{exp}, and xx; in particular, it is independent of the rounding mode rmrm and of the bound bb. Hence the number of digits retained, w=e−exp⁡′+1w = e - \operatorname{exp}' + 1, is a well-defined function of pp, exp⁡\operatorname{exp}, and xx alone. □

Let A(p1,exp⁡1,b1)\mathcal{A}(p_1,\operatorname{exp}_1,b_1) be a number format and let k≥0k \ge0. Write w1w_1 and w2w_2 for the number of digits that rnd⁡A(p1,exp⁡1,b1),rm(x)\operatorname{rnd}_{\mathcal{A}(p_1,\operatorname{exp}_1,b_1),rm}(x) and rnd⁡A(p1+k,exp⁡1−k,b1),rm(x)\operatorname{rnd}_{\mathcal{A}(p_1+k,\operatorname{exp}_1-k,b_1),rm}(x) round to. We show w2=w1+kw_2 = w_1 + k for every x≠0x \ne0.

Proof of Lemma 5.3. Fix x≠0x \ne0, and let e=⌊log⁡2∣x∣⌋e = \lfloor\log_2 |x| \rfloor denote the exponent of $x. By Lemma 5.2, we case split on p1p_1 and exp⁡1\operatorname{exp}_1 to determine exp⁡1′\operatorname{exp}'_1, the position of the least significant digit that rounding to A(p1,exp⁡1,∞)\mathcal{A}(p_1,\operatorname{exp}_1,\infty) retains:

  • If p1=∞p_1=\infty and exp⁡1>−∞\operatorname{exp}_1>-\infty, then exp⁡1′=exp⁡1\operatorname{exp}'_1=\operatorname{exp}_1. Since p1+k=∞p_1+k=\infty and exp⁡1−k>−∞\operatorname{exp}_1-k>-\infty, rounding to A(p1+k,exp⁡1−k,∞)\mathcal{A}(p_1+k,\operatorname{exp}_1-k,\infty) gives exp⁡2′=exp⁡1−k=exp⁡1′−k\operatorname{exp}'_2=\operatorname{exp}_1-k=\operatorname{exp}'_1-k.

  • If p1<∞p_1<\infty and exp⁡1=−∞\operatorname{exp}_1=-\infty, then exp⁡1′=e−p1+1\operatorname{exp}'_1=e-p_1+1. Since p1+k<∞p_1+k<\infty and exp⁡1−k=−∞\operatorname{exp}_1-k=-\infty, rounding to A(p1+k,exp⁡1−k,∞)\mathcal{A}(p_1+k,\operatorname{exp}_1-k,\infty) gives exp⁡2′=e−(p1+k)+1=exp⁡1′−k\operatorname{exp}'_2=e-(p_1+k)+1=\operatorname{exp}'_1-k.

  • If p1<∞p_1<\infty and exp⁡1>−∞\operatorname{exp}_1>-\infty, then exp⁡1′=max⁡(e−p1+1,exp⁡1)\operatorname{exp}'_1=\max(e-p_1+1,\operatorname{exp}_1). Since p1+k<∞p_1+k<\infty and exp⁡1−k>−∞\operatorname{exp}_1-k>-\infty, rounding to A(p1+k,exp⁡1−k,∞)\mathcal{A}(p_1+k,\operatorname{exp}_1-k,\infty) gives exp⁡2′=max⁡(e−(p1+k)+1,exp⁡1−k)=max⁡(e−p1+1,exp⁡1)−k=exp⁡1′−k\operatorname{exp}'_2=\max(e-(p_1+k)+1,\operatorname{exp}_1-k)=\max(e-p_1+1,\operatorname{exp}_1)-k=\operatorname{exp}'_1-k.

In all cases exp⁡2′=exp⁡1′−k\operatorname{exp}'_2=\operatorname{exp}'_1-k, so w2=e−exp⁡2′+1=(e−exp⁡1′+1)+k=w1+kw_2=e-\operatorname{exp}'_2+1=(e-\operatorname{exp}'_1+1)+k=w_1+k. □

In the case that k≥1k\ge1, rounding under RTO has a special property:

Proof of Lemma 5.4. We prove the biconditional, then the interval bound.

(⇒)(\Rightarrow) If xx is representable at precision ww, it is also representable at precision w+kw+k (pad with kk trailing zero digits), so RTO leaves it unchanged: x′=xx'=x. Hence x′x' is representable at precision ww.

(⇐)(\Leftarrow) We prove the contrapositive: if xx is unrepresentable at precision ww, then so is x′x'. If xx is representable at precision w+kw+k, then x′=xx'=x, which is unrepresentable at precision ww by assumption. Otherwise xx is unrepresentable at precision w+kw+k, and RTO rounds it to a value with an odd significand. Since k≥1k\ge1, the (w+k)(w+k)-th digit of x′x' is nonzero and lies below the ww-th digit, so x′x' is unrepresentable at precision ww.

For the interval bound, suppose xx is unrepresentable at precision ww and let y1<x<y2y_1<x<y_2 be its two nearest representable neighbors at precision ww. If x′=xx'=x, then y1<x′<y2y_1<x'<y_2 is immediate. Otherwise xx is unrepresentable at precision w+kw+k, so x′x' has an odd significand at precision w+kw+k, whereas y1y_1 and y2y_2—being representable at precision ww—have even significands at precision w+kw+k (their low kk digits are zero). RTO never rounds to an even value, so x′∉{y1,y2}x'\notin\{y_1,y_2\}; and since RTO rounds xx to one of its two neighbors at precision w+kw+k, both of which lie in [y1,y2][y_1,y_2], we conclude y1<x′<y2y_1<x'<y_2. □

We now prove each of the correct double rounding rules. We’ll start with the first three rules where both roundings use the same rounding mode.

Proof of rnd-RTZ-RTZ. Write F1=A(p1,exp⁡1,b1)F_1=\mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2=\mathcal{A}(p_2,\operatorname{exp}_2,b_2). Without loss of generality assume x>0x>0; the case x<0x<0 is symmetric, and x=0x=0 is fixed by RTZ in both formats. For a positive argument, RTZ returns the largest representable value of the format that does not exceed the argument.

Let z=rnd⁡F2,RTZ(x)z=\operatorname{rnd}_{F_2,\mathrm{RTZ}}(x) and w=rnd⁡F1,RTZ(z)w=\operatorname{rnd}_{F_1,\mathrm{RTZ}}(z), so w≤z≤xw\le z\le x and w∈F1w\in F_1. It remains to show that ww is the largest element of F1F_1 that does not exceed xx. Let y∈F1y\in F_1 with y≤xy\le x. Since F1⊆F2F_1\subseteq F_2, we have y∈F2y\in F_2, so y≤zy\le z, as zz is the largest element of F2F_2 not exceeding xx. Then y≤wy\le w, as ww is the largest element of F1F_1 not exceeding zz. Hence ww is the largest element of F1F_1 not exceeding xx, that is, w=rnd⁡F1,RTZ(x)w=\operatorname{rnd}_{F_1,\mathrm{RTZ}}(x).

Proof of rnd-RAZ-RAZ. Write F1=A(p1,exp⁡1,b1)F_1=\mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2=\mathcal{A}(p_2,\operatorname{exp}_2,b_2). Without loss of generality assume x>0x>0; the case x<0x<0 is symmetric, and x=0x=0 is fixed by RAZ in both formats. For a positive argument, RAZ returns the smallest representable value of the format that is at least the argument.

Let z=rnd⁡F2,RAZ(x)z=\operatorname{rnd}_{F_2,\mathrm{RAZ}}(x) and w=rnd⁡F1,RAZ(z)w=\operatorname{rnd}_{F_1,\mathrm{RAZ}}(z), so w≥z≥xw\ge z\ge x and w∈F1w\in F_1. It remains to show that ww is the smallest element of F1F_1 that is at least xx. Let y∈F1y\in F_1 with y≥xy\ge x. Since F1⊆F2F_1\subseteq F_2, we also have y∈F2y\in F_2, so y≥zy\ge z, as zz is the smallest element of F2F_2 at least xx. Then y≥wy\ge w, as ww is the smallest element of F1F_1 at least zz. Hence ww is the smallest element of F1F_1 at least xx, that is, w=rnd⁡F1,RAZ(x)w=\operatorname{rnd}_{F_1,\mathrm{RAZ}}(x).

Proof of rnd-RTO-RTO. Write F1=A(p1,exp⁡1,b1)F_1 = \mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2 = \mathcal{A}(p_2,\operatorname{exp}_2,b_2), where p2≥2p_2 \ge2. If x∈F1x \in F_1, both roundings fix xx and the identity is immediate, so assume x∉F1x \notin F_1.

Let w1w_1 and w2w_2 be the number of digits rounded to when rounding xx into F1F_1 and F2F_2, respectively; since F1⊆F2F_1 \subseteq F_2, w1≤w2w_1 \le w_2. Let z=rnd⁡F2,RTO(x)z = \operatorname{rnd}_{F_2,\mathrm{RTO}}(x) and w=rnd⁡F1,RTO(z)w = \operatorname{rnd}_{F_1,\mathrm{RTO}}(z). If w1=w2w_1 = w_2, then F2F_2 rounds xx at the same precision as F1F_1, so z=rnd⁡F1,RTO(x)∈F1z = \operatorname{rnd}_{F_1,\mathrm{RTO}}(x) \in F_1 and w=zw = z. Otherwise w1+1≤w2w_1 + 1 \le w_2, and by Lemma 5.4, zz is unrepresentable in F1F_1 and bracketed by the same two elements of F1F_1 as xx; rounding zz in F1F_1 therefore yields the same odd value as rounding xx. In either case, w=rnd⁡F1,RTO(x)w = \operatorname{rnd}_{F_1,\mathrm{RTO}}(x).

Finally, we prove the last three rules where the first rounding uses RTO and the second rounding uses a different rounding mode.

Proof of rnd-RTO-RTZ. Write F1=A(p1,exp⁡1,b1)F_1 = \mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2 = \mathcal{A}(p_2,\operatorname{exp}_2,b_2). Without loss of generality assume x>0x > 0; the case x<0x < 0 is symmetric, and x=0x = 0 is fixed by both roundings. If x∈F1x \in F_1, the identity is immediate, so assume x∉F1x \notin F_1.

Let w1w_1 and w2w_2 be the number of digits rounded to when rounding xx into F1F_1 and F2F_2. Since A(p1+1,exp⁡1−1,b1)⊆F2\mathcal{A}(p_1 + 1,\operatorname{exp}_1 - 1,b_1) \subseteq F_2, we have w1+1≤w2w_1 + 1 \le w_2 by Lemma 5.3. Let y1<x<y2y_1 < x < y_2 be the adjacent elements of F1F_1 about xx, so that rnd⁡F1,RTZ(x)=y1\operatorname{rnd}_{F_1,\mathrm{RTZ}}(x) = y_1. Set z=rnd⁡F2,RTO(x)z = \operatorname{rnd}_{F_2,\mathrm{RTO}}(x) and w=rnd⁡F1,RTZ(z)w = \operatorname{rnd}_{F_1,\mathrm{RTZ}}(z). Since w1+1≤w2w_1 + 1 \le w_2, Lemma 5.4 applies: zz is unrepresentable in F1F_1 and y1<z<y2y_1 < z < y_2. Hence zz shares the F1F_1-neighbors y1,y2y_1,y_2, and rounding it toward zero gives w=y1=rnd⁡F1,RTZ(x)w = y_1 = \operatorname{rnd}_{F_1,\mathrm{RTZ}}(x).

Proof of rnd-RTO-RAZ. Write F1=A(p1,exp⁡1,b1)F_1 = \mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2 = \mathcal{A}(p_2,\operatorname{exp}_2,b_2). Without loss of generality assume x>0x > 0; the case x<0x < 0 is symmetric, and x=0x = 0 is fixed by both roundings. If x∈F1x \in F_1, the identity is immediate, so assume x∉F1x \notin F_1.

Let w1w_1 and w2w_2 be the number of digits rounded to when rounding xx into F1F_1 and F2F_2. Since A(p1+1,exp⁡1−1,next⁡p1,exp⁡1(b1))⊆F2\mathcal{A}(p_1 + 1,\operatorname{exp}_1 - 1,\operatorname{next}_{p_1,\operatorname{exp}_1}(b_1)) \subseteq F_2, we have w1+1≤w2w_1 + 1 \le w_2 by Lemma 5.3. Let y1<x<y2y_1 < x < y_2 be the adjacent elements of F1F_1 about xx, so that rnd⁡F1,RAZ(x)=y2\operatorname{rnd}_{F_1,\mathrm{RAZ}}(x) = y_2. Set z=rnd⁡F2,RTO(x)z = \operatorname{rnd}_{F_2,\mathrm{RTO}}(x) and w=rnd⁡F1,RAZ(z)w = \operatorname{rnd}_{F_1,\mathrm{RAZ}}(z). Since w1+1≤w2w_1 + 1 \le w_2, Lemma 5.4 applies: zz is unrepresentable in F1F_1 and y1<z<y2y_1 < z < y_2. Hence zz shares the F1F_1-neighbors y1,y2y_1,y_2, and rounding it away from zero gives w=y2=rnd⁡F1,RAZ(x)w = y_2 = \operatorname{rnd}_{F_1,\mathrm{RAZ}}(x).

Proof of rnd-RTO-RNE. Write F1=A(p1,exp⁡1,b1)F_1 = \mathcal{A}(p_1,\operatorname{exp}_1,b_1) and F2=A(p2,exp⁡2,b2)F_2 = \mathcal{A}(p_2,\operatorname{exp}_2,b_2). Without loss of generality assume x>0x > 0; the case x<0x < 0 is symmetric, and x=0x = 0 is fixed by both roundings. If x∈F1x \in F_1, the identity is immediate, so assume x∉F1x \notin F_1.

Let w1w_1 and w2w_2 be the number of digits rounded to when rounding xx into … Overflow. The proofs above assume no rounding overflows. We now show that both roundings overflow together, completing ⟨F1,rm1⟩▹⟨F2,rm2⟩\langle F_1,rm_1\rangle\triangleright\langle F_2,rm_2\rangle. Fix x∈Rx \in\mathbb{R} and let yy, zz, and ww be the roundings of xx into F1F_1, of xx into F2F_2, and of zz into F1F_1, each ignoring the bound; rounding directly overflows when ∣y∣>b1|y| > b_1, and rounding through F2F_2 when ∣z∣>b2|z| > b_2 or ∣w∣>b1|w| > b_1. Each rule has a threshold TT, a value of F2F_2 by its containment premise, with two properties:

  • if ∣x∣>T|x| > T, then ∣y∣>b1|y| > b_1 and ∣w∣>b1|w| > b_1, so both overflow;

  • if ∣x∣≤T|x| \le T, then ∣z∣≤T≤b2|z| \le T \le b_2, and the rule’s proof applies to xx, since the premise places the values of F1F_1 up to TT in F2F_2; so w=yw = y, and both overflow or neither does.

Both use that rounding is monotone and returns representable values unchanged, so ∣x∣≤T|x| \le T implies ∣z∣≤T|z| \le T for T∈F2T \in F_2, and ∣x∣≥T|x| \ge T implies ∣y∣≥T|y| \ge T for T∈A(p1,exp1,∞)T \in\mathcal{A}(p_1,exp_1,\infty). For rnd-RAZ-RAZ, T=b1T = b_1: RAZ never decreases magnitude, so ∣x∣>b1|x| > b_1 gives ∣y∣≥∣x∣>b1|y| \ge|x| > b_1 and ∣w∣≥∣z∣≥∣x∣>b1|w| \ge|z| \ge|x| > b_1. For rnd-RTZ-RTZ, rnd-RTO-RTO, rnd-RTO-RTZ, and rnd-RTO-RAZ, T=next⁡p1,exp1(b1)T = \operatorname{next}_{p_1,exp_1}(b_1), a value of A(p1,exp1,∞)\mathcal{A}(p_1,exp_1,\infty) above b1b_1: ∣x∣>T|x| > T gives ∣y∣≥T|y| \ge T and ∣z∣≥T|z| \ge T, hence ∣w∣≥T>b1|w| \ge T > b_1. For rnd-RTO-RNE, T=next⁡p1+1,exp1−1(b1)T = \operatorname{next}_{p_1+1,exp_1-1}(b_1), the midpoint between b1b_1 and next⁡p1,exp1(b1)\operatorname{next}_{p_1,exp_1}(b_1): ∣x∣>T|x| > T gives ∣y∣≥next⁡p1,exp1(b1)|y| \ge\operatorname{next}_{p_1,exp_1}(b_1); and ∣z∣>T|z| > T, since RTO never rounds an inexact value onto TT, which has fewer digits than F2F_2 keeps, so ∣w∣≥next⁡p1,exp1(b1)|w| \ge\operatorname{next}_{p_1,exp_1}(b_1) as well.

Proof of rnd-Double. Let vv be an input. If vv is a special value, rounding through F2F_2 gives rnd⁡F1,rm1σ1,ω1(σ2(v))=σ1(v)\operatorname{rnd}^{\sigma_1,\omega_1}_{F_1,rm_1}(\sigma_2(v)) = \sigma_1(v), the direct rounding. Otherwise v=x∈Rv = x \in\mathbb{R}, and by ⟨F1,rm1⟩▹⟨F2,rm2⟩\langle F_1,rm_1\rangle\triangleright\langle F_2,rm_2\rangle either neither rounding overflows and the results agree, or both overflow and the direct rounding gives ω1(sgn⁡(x))\omega_1(\operatorname{sgn}(x)). In the latter case, rounding preserves sign: if ∣z∣>b2|z| > b_2, rounding through F2F_2 gives rnd⁡F1,rm1σ1,ω1(ω2(sgn⁡(x)))=ω1(sgn⁡(x))\operatorname{rnd}^{\sigma_1,\omega_1}_{F_1,rm_1}(\omega_2(\operatorname{sgn}(x))) = \omega_1(\operatorname{sgn}(x)); otherwise ∣w∣>b1|w| > b_1 and it gives ω1(sgn⁡(z))=ω1(sgn⁡(x))\omega_1(\operatorname{sgn}(z)) = \omega_1(\operatorname{sgn}(x)).

Format Inference

Recall that x∈A(p,exp,b)x \in\mathcal{A}(p,exp,b) means xx has precision at most pp (a significand of magnitude below 2p2^p), is an integer multiple of 2exp2^{exp}, and satisfies ∣x∣≤b|x| \le b. When an input parameter is infinite (p=∞p = \infty, exp=−∞exp = -\infty, or b=∞b = \infty), the matching output parameter is infinite too and the corresponding constraint is vacuous; we treat only the finite cases. Finite operands have finite sums and products, so special values arise only from special operands; the sets S⊕S_{\oplus} and S⊗S_{\otimes} follow by cases on the IEEE 754 rules, and we prove the numerical part below.

Proof of the ⊗\otimes rule. Let x∈A(p1,exp1,b1)x \in\mathcal{A}(p_1,exp_1,b_1) and y∈A(p2,exp2,b2)y \in\mathcal{A}(p_2,exp_2,b_2). We show x⋅y∈A(p1+p2,exp1+exp2,b1×b2)x \cdot y \in\mathcal{A}(p_1 + p_2, exp_1 + exp_2, b_1 \times b_2).

Precision. The precision constraints give representations x=s1×2e1x = s_1 \times2^{e_1} and y=s2×2e2y = s_2 \times2^{e_2} with ∣s1∣<2p1|s_1| < 2^{p_1} and ∣s2∣<2p2|s_2| < 2^{p_2}. Then

x⋅y=(s1s2)×2e1+e2,∣s1s2∣=∣s1∣∣s2∣<2p1⋅2p2=2p1+p2.x \cdot y = (s_1s_2) \times2^{e_1+e_2}, \qquad|s_1s_2| = |s_1||s_2| < 2^{p_1} \cdot2^{p_2} = 2^{p_1+p_2}.

so x⋅yx \cdot y has precision at most p1+p2p_1 + p_2.

Quantum. The quantum constraints give x=c1×2exp1x = c_1 \times2^{exp_1} and y=c2×2exp2y = c_2 \times2^{exp_2} for integers c1,c2c_1,c_2. Then x⋅y=(c1c2)×2exp1+exp2x \cdot y = (c_1c_2) \times2^{exp_1+exp_2} is an integer multiple of 2exp1+exp22^{exp_1+exp_2}.

Bound. From ∣x∣≤b1|x| \le b_1 and ∣y∣≤b2|y| \le b_2 we get ∣x⋅y∣=∣x∣∣y∣≤b1b2|x \cdot y| = |x||y| \le b_1b_2.

Proof of the ⊕\oplus rule. Let x∈A(p1,exp1,b1)x \in\mathcal{A}(p_1,exp_1,b_1) and y∈A(p2,exp2,b2)y \in\mathcal{A}(p_2,exp_2,b_2). We show x+y∈A(P,m,b1+b2)x + y \in\mathcal{A}(P,m,b_1+b_2), where

m=min⁡(exp1,exp2),N=⌊(b1+b2)/2m⌋,P=max⁡(1,⌈log⁡2(N+1)⌉).m = \min(exp_1,exp_2), \qquad N = \lfloor(b_1+b_2)/2^m \rfloor, \qquad P = \max(1,\lceil\log_2(N+1)\rceil).

Quantum. Since exp1,exp2≥m\mathit{exp}_1,\mathit{exp}_2 \ge m, the quantum constraints x=c1×2exp1x = c_1 \times2^{\mathit{exp}_1} and y=c2×2exp2y = c_2 \times2^{\mathit{exp}_2} rewrite at the finer quantum 2m2^m as

x=(c1×2exp1−m)×2m,y=(c2×2exp2−m)×2m,x = (c_1 \times2^{\mathit{exp}_1-m}) \times2^m,\qquad y = (c_2 \times2^{\mathit{exp}_2-m}) \times2^m,

with integer coefficients (the exponents expi−m\mathit{exp}_i-m are nonnegative). Hence x+y=c×2mx+y=c \times2^m where c=c1×2exp1−m+c2×2exp2−mc=c_1 \times2^{\mathit{exp}_1-m}+c_2 \times2^{\mathit{exp}_2-m} is an integer, so x+yx+y is an integer multiple of 2m2^m.

Bound. ∣x+y∣≤∣x∣+∣y∣≤b1+b2|x+y| \le|x|+|y| \le b_1+b_2.

Precision. Reusing the representation x+y=c×2mx+y=c \times2^m from the quantum step, the bound step gives

∣c∣×2m=∣x+y∣≤b1+b2,so∣c∣≤(b1+b2)/2m.|c| \times2^m=|x+y|\le b_1+b_2,\qquad\text{so}\qquad|c|\le(b_1+b_2)/2^m.

As cc is an integer, in fact ∣c∣≤⌊(b1+b2)/2m⌋=N|c|\le\lfloor(b_1+b_2)/2^m\rfloor=N. By definition of the ceiling logarithm,

N+1≤2⌈log⁡2(N+1)⌉≤2P,soN+1\le2^{\lceil\log_2(N+1)\rceil}\le2^P,\qquad\text{so}
∣c∣≤N<N+1≤2P.|c|\le N<N+1\le2^P.

Thus x+y=c×2mx+y=c \times2^m with ∣c∣<2P|c|<2^P; that is, x+yx+y has precision at most PP. □

References

  1. [1]2019. IEEE Standard for Floating-Point Arithmetic. IEEE Std 754-2019 (Revision of IEEE 754-2008) (2019), 1–84. doi:10.1109/IEEESTD.2019.8766229DOI
  2. [2]Andrew Appel and Ariel Kellison. 2024. VCFloat2: Floating-Point Error Analysis in Coq. In Proceedings of the 13th ACM SIGPLAN International Conference on Certified Programs and Proofs (London, UK) (CPP 2024). Association for Computing Machinery, New York, NY, USA, 14–29. doi:10.1145/3636501.3636953DOI
  3. [3]Heiko Becker, Robert Rabe, Eduard Roux, Magnus O. Myreen, Zachary Tatlock, Ramana Kumar, Yong Kiam Tan, and Anthony Fox. 2022. Verified Compilation and Optimization of Floating-Point Programs in CakeML. In European Conference on Object-Oriented Programming (ECOOP). LIPIcs. https://drops.dagstuhl.de/opus/volltexte/2022/16229/pdf/LIPIcs-ECOOP-2022-1.pdf
  4. [4]Sofiane Bessai, Dorra Ben Khalifa, Hanane Benmaghnia, and Matthieu Martel. 2022. Fixed-Point Code Synthesis Based on Constraint Generation. In Design and Architecture for Signal and Image Processing, Karol Desnos and Sergio Pertuz (Eds.). Springer International Publishing, Cham, 108–120.DOI
  5. [5]Sylvie Boldo and Guillaume Melquiond. 2005. When double rounding is odd. In 17th IMACS World Congress. Paris, France, 11. https://inria.hal.science/inria-00070603
  6. [6]Sylvie Boldo and Guillaume Melquiond. 2008. Emulation of a FMA and Correctly Rounded Sums: Proved Algorithms Using Rounding to Odd. IEEE Trans. Comput. 57, 4 (2008), 462–471. doi:10.1109/TC.2007.70819
  7. [7]Sylvie Boldo and Guillaume Melquiond. 2011. Flocq: A Numerical Library for Proving Floating-Point Algorithms in Coq. In 2011 IEEE 20th Symposium on Computer Arithmetic. 243–252. doi:10.1109/ARITH.2011.40
  8. [8]Ian Briggs, Yash Lad, and Pavel Panchekha. 2024. Implementation and Synthesis of Math Library Functions. Proc. ACM Program. Lang. 8, POPL, Article 32 (Jan. 2024), 28 pages. doi:10.1145/3632874
  9. [9]Nicolas Brisebarre, Guillaume Hanrot, Jean-Michel Muller, and Paul Zimmermann. 2025. Correctly-Rounded Evaluation of a Function: Why, How, and at What Cost? ACM Comput. Surv. 58, 1, Article 27 (Sept. 2025), 34 pages. doi:10.1145/3747840
  10. [10]Tung-Che Chang, Sehyeok Park, Jay P Lim, and Santosh Nagarakatte. 2026. FLoPS: Semantics, Operations, and Properties of P3109 Floating-Point Representations in Lean. arXiv:2602.15965 [cs.MS] https://arxiv.org/abs/2602.15965
  11. [11]Sylvain Chevillard, Mioara Joldeş, and Christoph Lauter. 2010. Sollya: an environment for the development of numerical codes. In Proceedings of the Third International Congress Conference on Mathematical Software (Kobe, Japan) (ICMS’10). Springer-Verlag, Berlin, Heidelberg, 28–31.
  12. [12]Wei-Fan Chiang, Mark Baranowski, Ian Briggs, Alexey Solovyev, Ganesh Gopalakrishnan, and Zvonimir Rakamarić. 2017. Rigorous floating-point mixed-precision tuning. SIGPLAN Not. 52, 1 (Jan. 2017), 300–315. doi:10.1145/3093333.3009846
  13. [13]Sangeeta Chowdhary and Santosh Nagarakatte. 2022. Fast shadow execution for debugging numerical errors using error free transformations. Proc. ACM Program. Lang. 6, OOPSLA2, Article 190 (Oct. 2022), 28 pages. doi:10.1145/3563353
  14. [14]Eva Darulova, Einar Horn, and Saksham Sharma. 2018. Sound mixed-precision optimization with rewriting. In Proceedings of the 9th ACM/IEEE International Conference on Cyber-Physical Systems (Porto, Portugal) (ICCPS ’18). IEEE Press, 208–219. doi:10.1145/ICCCPS.2018.00028arxiv.org/abs/1707.02118
  15. [15]Marc Daumas and Guillaume Melquiond. 2010. Certification of bounds on expressions involving rounded operators. ACM Trans. Math. Softw. 37, 1, Article 2 (Jan. 2010), 20 pages. doi:10.1145/1644001.1644003
  16. [16]Marc Daumas, Laurence Rideau, and Laurent Théry. 2001. A Generic Library for Floating-Point Numbers and Its Application to Exact Computing. In Proceedings of the 14th International Conference on Theorem Proving in Higher Order Logics (TPHOLs ’01). Springer-Verlag, Berlin, Heidelberg, 169–184.
  17. [17]Leonardo de Moura and Sebastian Ullrich. 2021. The Lean 4 Theorem Prover and Programming Language. In Automated Deduction – CADE 28. Springer International Publishing, 625–653. doi:10.1007/978-3-030-79876-5_37
  18. [18]Massimiliano Fasi and Mantas Mikaitis. 2023. CPFlo at: A C Library for Simulating Low-precision Arithmetic. ACM Trans. Math. Softw. 49, 2, Article 18 (June 2023), 32 pages. doi:10.1145/3585515DOI
  19. [19]Samuel A. Figueroa. 1995. When is double rounding innocuous? SIGNUM Newsl. 30, 3 (July 1995), 21–26. doi:10.1145/221332.221334
  20. [20]Goran Flegar, Florian Scheidegger, Vedran Novaković, Giovani Mariani, Andrés E. Tomás, A. Cristiano I Malossi, and Enrique S. Quintana-Ortí. 2019. FloatX: A C++ Library for Customized Floating-Point Arithmetic. ACM Trans. Math. Softw. 45, 4, Article 40 (Dec. 2019), 23 pages. doi:10.1145/3368086
  21. [21]Laurent Fousse, Guillaume Hanrot, Vincent Lefèvre, Patrick Pélissier, and Paul Zimmermann. 2007. MPFR: A multiple-precision binary floating-point library with correct rounding. ACM Trans. Math. Softw. 33, 2 (June 2007), 15 pages. doi:10.1145/1236463.1236468
  22. [22]Torbjörn Granlund and Yannomoto. 2017. Beating Floating Point at its Own Game: Posit Arithmetic. Supercomput. Front. Innov.: Int. J. 4, 2 (June 2017), 71–86. doi:10.14529/jsfi170206
  23. [23]Gustafson and Ynomoto. 2017. Beating Floating Point at its Own Game: Posit Arithmetic. Supercomput. Front. Innov.: Int. J. 4, 2 (June 2017), 71–86. doi:10.14529/jsfi170206DOI
  24. [24]John Harrison. 1999. A Machine-Checked Theory of Floating Point Arithmetic. In Proceedings of the 12th International Conference on Theorem Proving in Higher Order Logics (TPHOLs ’99). Springer-Verlag, Berlin, Heidelberg, 113–130.DOI
  25. [25]John R. Hauser. 2018. Berkeley SoftFloat: A Software Implementation of IEEE Floating-Point Arithmetic. Conforms to the IEEE Standard for Binary Floating-Point Arithmetic. https://www.jhauser.us/arithmetic/SoftFloat.html
  26. [26]Neil Henning. 2023. How costly is changing the hardware rounding mode? neilhenning.dev. Accessed: 2026-03-02. https://www.neilhenning.dev/posts/howcostlyischangingroundingmode/
  27. [27]IEEE SA P3109 Working Group. 2026. Interim Report on Binary Floating-point Formats for Machine Learning. Technical Report. Institute of Electrical and Electronics Engineers (IEEE). © 2026 by The Institute of Electrical and Electronics Engineers, Inc.. https://github.com/P3109/Public/blob/main/Shared%20Reports/IEEE%20WG%20P3109%20Interim%20Report.pdf
  28. [28]Maliha Islam and Mantas Mikaitis. 2026. Simulation of Custom-Precision OCP MX Block Floating-Point Formats and Arithmetic. arXiv:2607.12915 [cs.MS]. https://arxiv.org/abs/2607.12915
  29. [29]ISO/IEC JTC1/SC22/WG21. 2023. Working Draft, Standard for Programming Language C++. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf. N4950.
  30. [30]Anastasia Isychkova and Debashya Lohar. 2025. Cost of Soundness in Mixed-Precision Tuning. Proc. ACM Program. Lang. 9, OOPSLA2, Article 359 (Oct. 2025), 28 pages. doi:10.1145/3763137
  31. [31]Charles Jacobsen, Alexey Solovyev, and Ganesh Gopalakrishnan. 2015. A Parameterized Floating-Point Formalization in HOL Light. Electronic Notes in Theoretical Computer Science 317 (2015), 101–107. The Seventh and Eighth International Workshops on Numerical Software Verification (NSV). doi:10.1016/j.entcs.2015.10.010DOI
  32. [32]Andreas Kalaitzis et al. 2018. The bfloat16 floating-point format. Google AI Blog (2018). https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus
  33. [33]Ariel E. Kellison and Justin Hsu. 2024. Numerical Fuzz: A Type System for Rounding Error Analysis. Proc. ACM Program. Lang. 8, PLDI, Article 226 (June 2024), 25 pages. doi:10.1145/3656456DOI
  34. [34]Ariel E. Kellison, Laura Zielinski, David Bindel, and Justin Hsu. 2025. Bean: A Language for Backward Error Analysis. Proc. ACM Program. Lang. 9, PLDI, Article 221 (June 2025), 25 pages. doi:10.1145/3729324DOI
  35. [35]Olga Kuprianova and Christoph Lauter. 2014. MetaLib: A Mathematical Functions Code Generator. In Mathematical Software – ICMS 2014. 4th International Congress, Seoul, South Korea, August 5-9, 2014. Proceedings (Lecture Notes in Computer Science, Vol. 8592), Chee Yap Hoon Hong (Ed.). Springer, Seoul, South Korea, 713–717. doi:10.1007/978-3-662-44199-2_106
  36. [36]Vincent Lefèvre. 2013. SIPE: Small Integer Plus Exponent. In 2013 IEEE 21st Symposium on Computer Arithmetic. 99–106. doi:10.1109/ARITH.2013.22DOI
  37. [37]Siew Hoon Leong. 2020. SoftPosit. If you use this software, please cite it as indicated by the author. doi:10.5281/zenodo.3709035
  38. [38]Jay P. Lim and Santosh Nagarakatte. 2021. High performance correctly rounded math libraries for 32-bit floating point representations. In Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation (Virtual, Canada) (PLDI 2021). Association for Computing Machinery, New York, NY, USA, 359–374. doi:10.1145/3453483.3454049DOI
  39. [39]Jay P. Lim and Santosh Nagarakatte. 2022. One polynomial approximation to produce correctly rounded results of an elementary function for multiple representations and rounding modes. Proc. ACM Program. Lang. 6, POPL, Article 3 (Jan. 2022), 28 pages. doi:10.1145/3498664DOI
  40. [40]Shuming Ma, Hongyu Wang, Lingxiao Ma, Lei Wang, Wenhui Wang, Shaohan Huang, Li Dong, Ruiping Wang, Jilong Xue, and Furu Wei. 2024. The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits. arXiv:2402.17764 [cs.CL] https://arxiv.org/abs/2402.17764
  41. [41]Érik Martin-Dorel, Guillaume Melquiond, and Jean-Michel Muller. 2013. Some issues related to double rounding. BIT Numerical Mathematics 53, 4 (01 Dec 2013), 897–924. doi:10.1007/s10543-013-0436-2
  42. [42]Ramon E. Moore, R. Baker Kearfott, and Michael J. Cloud. 2009. Introduction to Interval Analysis. Society for Industrial and Applied Mathematics, USA.DOI
  43. [43]Jean-Michel Muller, Nicolas Brunie, Florent de Dinechin, Claude-Pierre Jeannerod, Mioara Joldes, Vincent Lefèvre, Guillaume Melquiond, Nathalie Revol, and Serge Torres. 2018. Handbook of Floating-point Arithmetic (2nd edition). Birkhäuser Basel. 1–627 pages. doi:10.1007/978-3-319-76526-6
  44. [44]Badreddine Noune, Philip Jones, Daniel Justus, Dominic Masters, and Carlo Luschi. 2022. 8-bit Numerical Formats for Deep Neural Networks. arXiv:2206.02915 [cs.LG] https://arxiv.org/abs/2206.02915
  45. [45]NVIDIA Corporation. 2020. NVIDIA A100 Tensor Core GPU Architecture Whitepaper. Technical Report. NVIDIA Corporation. https://images.nvidia.com/aem-dam/en-zz/Solutions/data-center/nvidia-ampere-architecture-whitepaper.pdf
  46. [46]Takeshi Ogita, Siegfried M. Rump, and Shin’ichi Oishi. 2005. Accurate Sum and Dot Product. SIAM Journal on Scientific Computing 26, 6 (2005), 1955–1988. arXiv:https://doi.org/10.1137/030601818 doi:10.1137/030601818
  47. [47]E. Theodore L. Omtzigt and James Quinlan. 2022. Universal: Reliable, Reproducible, and Energy-Efficient Numerics. In Conference on Next Generation Arithmetic. Springer, 100–116.DOI
  48. [48]E. Theodore L. Omtzigt and James Quinlan. 2023. Universal Numbers Library: Multi-format Variable Precision Arithmetic Library. Journal of Open Source Software 8, 83 (2023), 5072. doi:10.21105/joss.05072DOI
  49. [49]Open Compute Project. 2023. OCP Microscaling Formats (MX) Specification, Version 1.0. https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
  50. [50]Pavel Panchekha, Alex Sanchez-Stern, James R. Wilcox, and Zachary Tatlock. 2015. Automatically improving accuracy for floating point expressions. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (Portland, OR, USA) (PLDI ’15). Association for Computing Machinery, New York, NY, USA, 1–11. doi:10.1145/2737924.2737959DOI
  51. [51]Tahina Ramanandro, Paul Mountcastle, Benoît Meister, and Richard Lethin. 2016. A unified Cog framework for verifying C programs with floating-point computations. In Proceedings of the 5th ACM SIGPLAN Conference on Certified Programs and Proofs (St. Petersburg, FL, USA) (CPP 2016). Association for Computing Machinery, New York, NY, USA, 15–26. doi:10.1145/2854065.2854066
  52. [52]Rick Regan. 2014. GCC Avoids Double Rounding Errors With Round-To-Odd. Exploring Binary. Accessed: 2026-03-01. https://www.exploringbinary.com/gcc-avoids-double-rounding-errors-with-round-to-odd/
  53. [53]Bita Darvish Rouhani, Ritchie Zhao, Ankit More, Mathew Hall, Alireza Khodamoradi, Summer Deng, Dhruv Choudhary, Marius Cornea, Eric Dellinger, Kristof Denolf, Stosic Dusan, Venmugil Elango, Maximilian Golub, Alexander Heinecke, Phil James-Roxby, Dharmesh Jani, Gaurav Kolhe, Martin Langhammer, Ada Li, Levi Melnick, Maral Mesmakhosroshahi, Andres Rodriguez, Michael Schulte, Rasoul Shafipour, Lei Shao, Michael Siu, Pradeep Dubey, Paulius Mickevicius, Maxim Naumov, Colin Verrilli, Ralph Wittig, Doug Burger, and Eric Chung. 2023. Microscaling Data Formats for Deep Learning. arXiv:2310.10537 [cs.LG] https://arxiv.org/abs/2310.10537
  54. [54]Pierre Roux. 2014. Innocuous Double Rounding of Basic Arithmetic Operations. Journal of Formalized Reasoning 7, 1 (Jan. 2014), 131–142. doi:10.6092/issn.1972-5787/4359DOI
  55. [55]Cindy Rubio-González, Cuong Nguyen, Hong Diep Nguyen, James Demmel, William Kahan, Koushik Sen, David H. Bailey, Costin Iancu, and David Hough. 2013. Precimonious: tuning assistant for floating-point precision. In Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis (Denver, Colorado) (SC ’13). Association for Computing Machinery, New York, NY, USA, Article 27, 12 pages. doi:10.1145/2503210.2503296
  56. [56]Siegfried M. Rump. 2016. IEEE754 Precision-k base-β Arithmetic Inherited by Precision-m Base-β for k < m. ACM Trans. Math. Softw. 43, 3, Article 20 (Dec. 2016), 15 pages. doi:10.1145/2785965
  57. [57]Brett Saiki, Jackson Brough, Jonas Regehr, Jesus Ponce, Varun Pradeep, Aditya Akhilashwewaran, Zachary Tatlock, and Pavel Panchekha. 2025. Target-Aware Implementation of Real Expressions. In Proceedings of the 30th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1 (Rotterdam, Netherlands) (ASPLOS ’25). Association for Computing Machinery, New York, NY, USA, 1069–1083. doi:10.1145/3669940.3707277
  58. [58]Jonathan Richard Shewchuk. 1997. Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates. Discrete & Computational Geometry 18, 3 (Oct. 1997), 305–363.DOI
  59. [59]Alexey Solovyev, Marek S. Baranowski, Ian Briggs, Charles Jacobsen, Zvonimir Rakamarić, and Ganesh Gopalakrishnan. 2018. Rigorous Estimation of Floating-Point Round-Off Errors with Symbolic Taylor Expansions. ACM Trans. Program. Lang. Syst. 41, 1, Article 2 (Dec. 2018), 39 pages. doi:10.1145/3230733DOI
  60. [60]E.E. Swartzlander and A.G. Alexopoulos. 1975. The Sign/Logarithm Number System. IEEE Trans. Comput. C-24, 12 (1975), 1238–1242. doi:10.1109/T-C.1975.224172DOI
  61. [61]The Coq Development Team. 2023. The Coq Proof Assistant. https://coq.inria.fr
  62. [62]Hongyu Wang, Shuming Ma, Li Dong, Shaohan Huang, Huijie Wang, Lingxiao Ma, Fan Yang, Ruiping Wang, Yi Wu, and Furu Wei. 2023. BitNet: Scaling 1-bit Transformers for Large Language Models. arXiv:2310.11453 [cs.CL] https://arxiv.org/abs/2310.11453
  63. [63]Niko Zurstraßen, Nils Bosbach, Jan Moritz Joseph, Lukas Jünger, Jan Henrik Weinstock, and Rainer Leupers. 2023. Efficient RISC-V-on-x64 Floating Point Simulation. In 2023 IEEE 41st International Conference on Computer Design (ICCD). 558–565. doi:10.1109/ICCD58317.2023.00090DOI
  64. [64]Niko Zurstraßen, Nils Bosbach, and Rainer Leupers. 2025. FloppyFloat: An Open Source Floating Point Library for Instruction Set Simulators. In 2025 Design, Automation & Test in Europe Conference (DATE). 1–6. doi:10.23919/DATE64628.2025.10992803DOI

Paper details

vlnc:W_y37e846u
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents