Rust 1.98 Adds Algebraic Floating-Point Methods Akin To "-ffast-math"

Written by Michael Larabel in Programming on 20 August 2026 at 01:29 PM EDT. 75 Comments
PROGRAMMING
Rust 1.98 released today and is headlined the debut of new algebraic floating-point methods.

Rust 1.98 introduces algebraic floating-point methods that are akin to using the "--fast-math" option with other languages/compilers. The Rust 1.98 release announcement explains of these optimized algebraic methods:
"The floating-point types f32 and f64 now have "algebraic" methods for addition, subtraction, multiplication, division, and remainder. These allow optimizations on these operations using the algebraic properties of real numbers, even though these properties do not hold with the limitations of floating-point representations. The exact set of optimizations is not specified, but may be similar to the kind of optimization you would see with the -ffast-math option in other languages.

For example, floating-point addition is not associative, so a sum like a + b + c + d must be evaluated in the left-associative order in which it is parsed, like ((a + b) + c) + d. If you write the same sum as a chain of algebraic_add calls, then the compiler is free to reorder it, perhaps like (a + b) + (c + d) to evaluate the partial sums simultaneously. Broader loop-vectorization is often enabled by using these algebraic methods as well.

These methods are non-deterministic, since the compiler is free to choose different optimizations, but they never cause undefined behavior."

Similar to using -ffast-math elsewhere, the Rust documentation does warn:
"Because of the unpredictable nature of compiler optimizations, the same inputs may produce different results even within a single program run. Unsafe code must not rely on any property of the return value for soundness. However, implementations will generally do their best to pick a reasonable tradeoff between performance and accuracy of the result."

These algebraic methods came as a result of this 2025 issue over simple dot products in Rust being up to 8x slower than C++ on modern x86_64 CPUs due to the compiler not reordering floating point operations for better vectorization.

Rust code example


Rust 1.98 also brings buffered integer formatting and other changes as outlined in the announcement on Rust-Lang.org.
Related News
About The Author

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week