[libc-commits] [libc] [libc][math][c23] Add {getpayload, setpayload, setpayloadsig}f16 C23 math functions (PR #95159)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 19 20:41:55 PDT 2024
================
@@ -265,6 +265,48 @@ totalordermag(T x, T y) {
return FPBits<T>(x).abs().uintval() <= FPBits<T>(y).abs().uintval();
}
+template <typename T>
+LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> getpayload(T x) {
+ using FPBits = FPBits<T>;
+ FPBits x_bits(x);
+
+ if (!x_bits.is_nan())
+ return T(-1.0);
+
+ return T(x_bits.uintval() & (FPBits::FRACTION_MASK >> 1));
+}
+
+template <bool IsSignaling, typename T>
+LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool>
+setpayload(T *res, T pl) {
----------------
lntue wrote:
change to `T& res`
https://github.com/llvm/llvm-project/pull/95159
More information about the libc-commits
mailing list