[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 12:50:56 PDT 2025
    
    
  
================
@@ -571,6 +572,10 @@ template <> float128 MPFRNumber::as<float128>() const {
   return mpfr_get_float128(value, mpfr_rounding);
 }
 
+template <> bfloat16 MPFRNumber::as<bfloat16>() const {
+  return fputil::cast<bfloat16>(mpfr_get_flt(value, mpfr_rounding));
+}
+
 #endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
----------------
overmighty wrote:
Took me too long to realize this:
```suggestion
#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
template <> bfloat16 MPFRNumber::as<bfloat16>() const {
  return fputil::cast<bfloat16>(mpfr_get_flt(value, mpfr_rounding));
}
```
https://github.com/llvm/llvm-project/pull/144463
    
    
More information about the libc-commits
mailing list