[libc][math] Add EXP_MANT_MASK when long double is double or quad
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 10 Jun 2022 16:47:40 +0000 (18:47 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 10 Jun 2022 16:48:31 +0000 (18:48 +0200)
libc/src/__support/FPUtil/FloatProperties.h

index ad52a4066e1e68033026e37ec5ba5273c6309071..6fc8b6ac1bb06f81b1f34da5cabc099787067a9e 100644 (file)
@@ -89,6 +89,11 @@ template <> struct FloatProperties<long double> {
   static constexpr uint32_t EXPONENT_BIAS =
       FloatProperties<double>::EXPONENT_BIAS;
 
+  static constexpr BitsType EXP_MANT_MASK =
+      FloatProperties<double>::EXP_MANT_MASK;
+  static_assert(EXP_MANT_MASK == ~SIGN_MASK,
+                "Exponent and mantissa masks are not as expected.");
+
   // If a number x is a NAN, then it is a quiet NAN if:
   //   QuietNaNMask & bits(x) != 0
   // Else, it is a signalling NAN.
@@ -138,6 +143,10 @@ template <> struct FloatProperties<long double> {
   static constexpr BitsType EXPONENT_MASK = ~(SIGN_MASK | MANTISSA_MASK);
   static constexpr uint32_t EXPONENT_BIAS = 16383;
 
+  static constexpr BitsType EXP_MANT_MASK = MANTISSA_MASK + EXPONENT_MASK;
+  static_assert(EXP_MANT_MASK == ~SIGN_MASK,
+                "Exponent and mantissa masks are not as expected.");
+
   // If a number x is a NAN, then it is a quiet NAN if:
   //   QuietNaNMask & bits(x) != 0
   // Else, it is a signalling NAN.