MSVC is experimenting with correctly-rounded math (LLVM libc)

Since 2015, the math functions in cmath and cstdlib are supplied by the C runtime via math.h and stdlib.h, which Microsoft ships as part of the Universal C Runtime (UCRT).

In the modern day, the UCRT math functions have known mathematical inaccuracies. See Accuracy of Mathematical Functions in Single, Double, Double Extended, and Quadruple Precision by Gladman, et al. for more info (it’s hot off the press). These inaccuracies stem from implementations that are quite old, dating to times when accuracy was often computationally infeasible.

We found that the LLVM C Library had already made incredible progress tackling the math portions of the C runtime. The project upholds accuracy as the primary goal, aiming for correct rounding in all rounding modes, with Gladman, et al. confirming the project’s success. By targeting mathematical accuracy, the library effectively codifies a stable interface that allows for implementation flexibility and optimization. The library is actively maintained and has a healthy community supporting it.

MSVC C++23: constexpr cmath with LLVM Libc - C++ Team Blog

Also note that:

  • LLVM-libc provides some correctly rounded functions (see links below): claimed accuracy of LLVM functions
  • seven binary64 functions are integrated into the GNU libc up from release 2.43 (…), and the following binary32 functions are integrated into the GNU libc up from release 2.42 (…)
  • AMD libm (since 4.2) integrates tanhf from CORE-MATH, and uses some CORE-MATH test cases for its erf function
  • the Intel Math Library or IML (checked with 2026.1.0) includes some (apparently undocumented) cr_xxx functions

The CORE-MATH project

And Rust libm (compiler-builtins)

It seems more and more projects are moving toward correctly-rounded libm.
Does Julia need to follow this wave?

Right now Julia’s math is ported from openlibm (and FDLIBM),
which is not correctly rounded.

And maybe now is a good time to remove openlibm as a dependency?