[libc-commits] [libc] [libc][math][c++23] Add {frexp, ilogb, ldexp, llogb, logb}bf16 math functions (PR #154427)

Krishna Pandey via libc-commits libc-commits at lists.llvm.org
Sun Aug 24 08:16:08 PDT 2025


================
@@ -354,7 +354,10 @@ LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> getpayload(T x) {
 
     return static_cast<T>(payload_dfloat);
   } else {
-    return static_cast<T>(payload);
+    if constexpr (cpp::is_same_v<T, bfloat16>)
+      return T(static_cast<int>(payload));
----------------
krishna2803 wrote:

i realised we do have:
https://github.com/llvm/llvm-project/blob/3c062b90afff255b285d4703ba0196fbb5d06347/libc/src/__support/FPUtil/bfloat16.h#L35-L43

so, the if-else should be needed. removed in [3c062b90](https://github.com/llvm/llvm-project/pull/154427/commits/3c062b90afff255b285d4703ba0196fbb5d06347)

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


More information about the libc-commits mailing list