[libc-commits] [libc] [libc][stdfix] Implement `countlsfx` functions (PR #114318)
via libc-commits
libc-commits at lists.llvm.org
Sat Nov 2 18:53:49 PDT 2024
================
@@ -66,6 +67,23 @@ template <typename T> struct FXBits {
}
}
+ // Clause 6.2.6.3 of ISO/IEC TR 18037 defines the value bits of a fixed-point
+ // type to include the integral and fraction bits but not padding nor sign
+ // bits.
+ //
+ // This function returns the value bits, right-aligned, as an unsigned integer
+ // type which is at least large enough to hold them all.
+ //
+ // Note the integral and fraction bits are contiguous. The rightmost bits in
+ // the returned value are the fraciton bits, then immediately left of those
+ // are the integral bits.
+ //
+ // Any left-padding in the return value is guaranteed to be zero.
+ LIBC_INLINE constexpr StorageType get_value_bits() {
+ constexpr StorageType VALUE_MASK = INTEGRAL_MASK | FRACTION_MASK;
----------------
duncpro wrote:
So, make `VALUE_MASK` a constant in `FXBits` just like how we already have `FRACTION_MASK`, etc.
Then, include an additional `TOTAL_MASK` that includes the sign bit as well.
Is that right?
https://github.com/llvm/llvm-project/pull/114318
More information about the libc-commits
mailing list