[libc-commits] [libc] [libc][stdfix] Add round functions for fixed point types. (PR #81994)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Fri Feb 16 07:39:24 PST 2024


================
@@ -19,6 +21,36 @@
 
 namespace LIBC_NAMESPACE::fixed_point {
 
+// Bit-wise operations are not available for fixed point types yet.
+template <typename T>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_fixed_point_v<T>, T>
+bit_and(T x, T y) {
+  using BitType = typename FXRep<T>::StorageType;
+  static_assert(sizeof(BitType) * CHAR_BIT == sizeof(T) * CHAR_BIT);
----------------
gchatelet wrote:

The two `* CHAR_BIT` are unnecessary.

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


More information about the libc-commits mailing list