[libc-commits] [libc] [libc][math][c++23] Add bfloat16 support in LLVM libc (PR #144463)

via libc-commits libc-commits at lists.llvm.org
Tue Jul 8 08:57:31 PDT 2025


================
@@ -169,6 +170,17 @@ class MPFRNumber {
     mpfr_set_sj(value, x, mpfr_rounding);
   }
 
+  // BFloat16
+  template <typename XType,
+            cpp::enable_if_t<cpp::is_same_v<bfloat16, XType>, int> = 0>
+  explicit MPFRNumber(XType x, unsigned int precision = 8,
----------------
overmighty wrote:

~~Same here. Could you move this above, between the constructor that takes a `float128` and the constructor that takes an integer?~~

Actually, we won't want `precision = 8` when we'll be testing math functions, it's only when testing conversion functions that 8 is enough. So maybe we should just merge this with the first non-default constructor above that currently supports both `float` and `float16`. @lntue thoughts?

https://github.com/llvm/llvm-project/pull/144463


More information about the libc-commits mailing list