[libc-commits] [libc] [libc][NFC] Reuse `FloatProperties` constant instead of creating new ones (PR #75187)

Clement Courbet via libc-commits libc-commits at lists.llvm.org
Tue Dec 12 06:23:12 PST 2023


================
@@ -87,49 +87,55 @@ template <FPType fp_type>
 struct FPProperties : public internal::FPBaseProperties<fp_type> {
 private:
   using UP = internal::FPBaseProperties<fp_type>;
-  using UP::EXP_BITS;
-  using UP::SIG_BITS;
-  using UP::TOTAL_BITS;
+  // The number of bits to represent sign. For documentation purpose, always 1.
+  LIBC_INLINE_VAR static constexpr int SIGN_BITS = 1;
+  using UP::EXP_BITS;   // The number of bits for the *exponent* part
+  using UP::SIG_BITS;   // The number of bits for the *significand* part
+  using UP::TOTAL_BITS; // For convenience, the sum of `SIG_BITS`, `EXP_BITS`,
+                        // and `SIGN_BITS`.
+  static_assert(SIGN_BITS + EXP_BITS + SIG_BITS == TOTAL_BITS);
 
 public:
   using UIntType = typename UP::UIntType;
----------------
legrosbuffle wrote:

Lets' use this as an opportunity to document this.

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


More information about the libc-commits mailing list