[libc-commits] [libc] [libc][math][c23] Add floorf16 C23 math function (PR #94001)

via libc-commits libc-commits at lists.llvm.org
Fri May 31 11:12:41 PDT 2024


================
@@ -43,12 +44,15 @@ LIBC_INLINE T trunc(T x) {
     return FPBits<T>::zero(bits.sign()).get_val();
 
   int trim_size = FPBits<T>::FRACTION_LEN - exponent;
-  bits.set_mantissa((bits.get_mantissa() >> trim_size) << trim_size);
+  StorageType trunc_mantissa =
+      static_cast<StorageType>((bits.get_mantissa() >> trim_size) << trim_size);
+  bits.set_mantissa(trunc_mantissa);
----------------
overmighty wrote:

Mantissa truncation is done multiple times in the file, so it could be extracted into a function, but doing it now would conflict with https://github.com/llvm/llvm-project/pull/93986.

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


More information about the libc-commits mailing list