
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 1.98 also brings buffered integer formatting and other changes as outlined in the announcement on Rust-Lang.org .