[libc-commits] [libc] 6ee5bae - [libc][math] Add EXP_MANT_MASK when long double is double or quad
Benjamin Kramer via libc-commits
libc-commits at lists.llvm.org
Fri Jun 10 09:48:49 PDT 2022
Author: Benjamin Kramer
Date: 2022-06-10T18:48:31+02:00
New Revision: 6ee5baeb9774622880bffebac8afc948347e25e4
URL: https://github.com/llvm/llvm-project/commit/6ee5baeb9774622880bffebac8afc948347e25e4
DIFF: https://github.com/llvm/llvm-project/commit/6ee5baeb9774622880bffebac8afc948347e25e4.diff
LOG: [libc][math] Add EXP_MANT_MASK when long double is double or quad
Added:
Modified:
libc/src/__support/FPUtil/FloatProperties.h
Removed:
################################################################################
diff --git a/libc/src/__support/FPUtil/FloatProperties.h b/libc/src/__support/FPUtil/FloatProperties.h
index ad52a4066e1e6..6fc8b6ac1bb06 100644
--- a/libc/src/__support/FPUtil/FloatProperties.h
+++ b/libc/src/__support/FPUtil/FloatProperties.h
@@ -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.
More information about the libc-commits
mailing list