[libc-commits] [libc] [libc][math][c23] Add MPFR unit tests for {ceil, floor, round, roundeven, trunc}f16 (PR #94383)

via libc-commits libc-commits at lists.llvm.org
Wed Jun 5 05:43:54 PDT 2024


================
@@ -585,6 +594,10 @@ template <> long double MPFRNumber::as<long double>() const {
   return mpfr_get_ld(value, mpfr_rounding);
 }
 
+template <> float16 MPFRNumber::as<float16>() const {
+  return static_cast<float16>(mpfr_get_flt(value, mpfr_rounding));
----------------
lntue wrote:

This can lead to double-rounding errors.  Use `mpfr_get_d` for now to reduce the chance of double-rounding errors, and add a TODO to either show that double-rounding errors won't happen or find a better way to avoid it.

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


More information about the libc-commits mailing list