[libc-commits] [libc] [libc][stdfix] Implement fixed point fxbits functions in llvm-libc (PR #114912)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed Nov 6 15:49:59 PST 2024


================
@@ -163,6 +163,10 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
   return bit_and((x + round_bit), rounding_mask);
 }
 
+template <typename T, typename XType> LIBC_INLINE constexpr T fx_bits(XType x) {
+  return cpp::bit_cast<T, XType>(x);
+}
+
----------------
michaelrj-google wrote:

instead of defining a new function, you can just use `FXBits<T> bits(x); return bits.get_val<some_int_type>();` in the functions below

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


More information about the libc-commits mailing list