// static long double const log10Two = 0.30102999566398119521373889472449L; // log10(2.)
// It is more portable useful to use a Boost macro
// See https://www.boost.org/doc/libs/release/libs/config/doc/html/boost_config/boost_macro_reference.html
-BOOST_STATIC_CONSTEXPR long double log10Two = 0.30102999566398119521373889472449L;
+static constexpr long double log10Two = 0.30102999566398119521373889472449L;
// which expands to static constexpr on standard C++11 and up, but static const on earlier versions.
/*`By default, output would only show the standard 6 decimal digits,
int max_digits10()
{
int significand_digits = std::numeric_limits<T>::digits;
- // BOOST_CONSTEXPR_OR_CONST int significand_digits = std::numeric_limits<T>::digits;
+ // constexpr int significand_digits = std::numeric_limits<T>::digits;
return static_cast<int>(ceil(1 + significand_digits * log10Two));
} // template <typename T> int max_digits10()
// Used to test max_digits10<>() function below.
-//#define BOOST_NO_CXX11_NUMERIC_LIMITS
BOOST_AUTO_TEST_CASE(test_numeric_limits_snips)
{
typedef float T;
-#if defined BOOST_NO_CXX11_NUMERIC_LIMITS
- // No max_digits10 implemented.
- std::cout.precision(max_digits10<T>());
-#else
- #if(_MSC_VER <= 1600)
- // The MSVC 2010 version had the wrong value for std::numeric_limits<float>::max_digits10.
- std::cout.precision(max_digits10<T>());
- #else // Use the C++11 max_digits10.
- std::cout.precision(std::numeric_limits<T>::max_digits10);
- std::cout.precision(std::numeric_limits<T>::digits10);
- std::cout.setf(std::ios_base::showpoint); // Append any trailing zeros,
- // or more memorably
- std::cout << std::showpoint << std::endl; //
- #endif
-#endif
+ std::cout.precision(std::numeric_limits<T>::max_digits10);
+ std::cout.precision(std::numeric_limits<T>::digits10);
+ std::cout.setf(std::ios_base::showpoint); // Append any trailing zeros,
+ // or more memorably
+ std::cout << std::showpoint << std::endl; //
std::cout << "std::cout.precision(max_digits10) = " << std::cout.precision() << std::endl; // 9
typedef double T;
bool denorm = std::numeric_limits<T>::denorm_min() < (std::numeric_limits<T>::min)();
- BOOST_ASSERT(denorm);
+ BOOST_MP_ASSERT(denorm);
//] [/max_digits10_6]
}
ss.imbue(new_locale);
T inf = std::numeric_limits<T>::infinity();
ss << inf; // Write out.
- BOOST_ASSERT(ss.str() == "inf");
+ BOOST_MP_ASSERT(ss.str() == "inf");
T r;
ss >> r; // Read back in.
- BOOST_ASSERT(inf == r); // Confirms that the floating-point values really are identical.
+ BOOST_MP_ASSERT(inf == r); // Confirms that the floating-point values really are identical.
std::cout << "infinity output was " << ss.str() << std::endl;
std::cout << "infinity input was " << r << std::endl;
}
T n;
T NaN = std::numeric_limits<T>::quiet_NaN();
ss << NaN; // Write out.
- BOOST_ASSERT(ss.str() == "nan");
+ BOOST_MP_ASSERT(ss.str() == "nan");
std::cout << "NaN output was " << ss.str() << std::endl;
ss >> n; // Read back in.
std::cout << "NaN input was " << n << std::endl;