mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-09 23:22:54 +00:00
Merge branch 'issue174' into develop
This commit is contained in:
@@ -78,7 +78,7 @@ class cpp_dec_float
|
||||
public:
|
||||
typedef mpl::list<boost::long_long_type> signed_types;
|
||||
typedef mpl::list<boost::ulong_long_type> unsigned_types;
|
||||
typedef mpl::list<long double> float_types;
|
||||
typedef mpl::list<double, long double> float_types;
|
||||
typedef ExponentType exponent_type;
|
||||
|
||||
static const boost::int32_t cpp_dec_float_radix = 10L;
|
||||
@@ -162,8 +162,8 @@ class cpp_dec_float
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::half();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::double_min();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::double_max();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_max();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_min();
|
||||
//cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_max();
|
||||
//cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_min();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_long_max();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_long_min();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::ulong_long_max();
|
||||
@@ -175,6 +175,18 @@ class cpp_dec_float
|
||||
|
||||
static initializer init;
|
||||
|
||||
struct long_double_initializer
|
||||
{
|
||||
long_double_initializer()
|
||||
{
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_max();
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_min();
|
||||
}
|
||||
void do_nothing() {}
|
||||
};
|
||||
|
||||
static long_double_initializer linit;
|
||||
|
||||
public:
|
||||
// Constructors
|
||||
cpp_dec_float() BOOST_MP_NOEXCEPT_IF(noexcept(array_type())) : data(),
|
||||
@@ -331,20 +343,20 @@ class cpp_dec_float
|
||||
static const cpp_dec_float& double_min()
|
||||
{
|
||||
init.do_nothing();
|
||||
static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::min)()));
|
||||
static cpp_dec_float val((std::numeric_limits<double>::min)());
|
||||
return val;
|
||||
}
|
||||
|
||||
static const cpp_dec_float& double_max()
|
||||
{
|
||||
init.do_nothing();
|
||||
static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::max)()));
|
||||
static cpp_dec_float val((std::numeric_limits<double>::max)());
|
||||
return val;
|
||||
}
|
||||
|
||||
static const cpp_dec_float& long_double_min()
|
||||
{
|
||||
init.do_nothing();
|
||||
linit.do_nothing();
|
||||
#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::min)()));
|
||||
#else
|
||||
@@ -355,7 +367,7 @@ class cpp_dec_float
|
||||
|
||||
static const cpp_dec_float& long_double_max()
|
||||
{
|
||||
init.do_nothing();
|
||||
linit.do_nothing();
|
||||
#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::max)()));
|
||||
#else
|
||||
@@ -434,7 +446,8 @@ class cpp_dec_float
|
||||
return *this;
|
||||
}
|
||||
|
||||
cpp_dec_float& operator=(long double v);
|
||||
template <class Float>
|
||||
typename boost::enable_if_c<boost::is_floating_point<Float>::value, cpp_dec_float&>::type operator=(Float v);
|
||||
|
||||
cpp_dec_float& operator=(const char* v)
|
||||
{
|
||||
@@ -624,6 +637,8 @@ class cpp_dec_float
|
||||
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
typename cpp_dec_float<Digits10, ExponentType, Allocator>::initializer cpp_dec_float<Digits10, ExponentType, Allocator>::init;
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
typename cpp_dec_float<Digits10, ExponentType, Allocator>::long_double_initializer cpp_dec_float<Digits10, ExponentType, Allocator>::linit;
|
||||
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
const boost::int32_t cpp_dec_float<Digits10, ExponentType, Allocator>::cpp_dec_float_radix;
|
||||
@@ -1564,6 +1579,7 @@ double cpp_dec_float<Digits10, ExponentType, Allocator>::extract_double() const
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale::classic());
|
||||
|
||||
ss << str(std::numeric_limits<double>::digits10 + (2 + 1), std::ios_base::scientific);
|
||||
|
||||
@@ -1610,6 +1626,7 @@ long double cpp_dec_float<Digits10, ExponentType, Allocator>::extract_long_doubl
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss.imbue(std::locale::classic());
|
||||
|
||||
ss << str(std::numeric_limits<long double>::digits10 + (2 + 1), std::ios_base::scientific);
|
||||
|
||||
@@ -2249,7 +2266,8 @@ cpp_dec_float<Digits10, ExponentType, Allocator>::cpp_dec_float(const double man
|
||||
}
|
||||
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, ExponentType, Allocator>::operator=(long double a)
|
||||
template <class Float>
|
||||
typename boost::enable_if_c<boost::is_floating_point<Float>::value, cpp_dec_float<Digits10, ExponentType, Allocator>&>::type cpp_dec_float<Digits10, ExponentType, Allocator>::operator=(Float a)
|
||||
{
|
||||
// Christopher Kormanyos's original code used a cast to boost::long_long_type here, but that fails
|
||||
// when long double has more digits than a boost::long_long_type.
|
||||
@@ -2275,7 +2293,7 @@ cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, Expone
|
||||
return *this = nan();
|
||||
|
||||
int e;
|
||||
long double f, term;
|
||||
Float f, term;
|
||||
*this = zero();
|
||||
|
||||
f = frexp(a, &e);
|
||||
@@ -2778,10 +2796,15 @@ inline void eval_convert_to(boost::long_long_type* result, const cpp_dec_float<D
|
||||
*result = val.extract_signed_long_long();
|
||||
}
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
inline void eval_convert_to(long double* result, cpp_dec_float<Digits10, ExponentType, Allocator>& val)
|
||||
inline void eval_convert_to(long double* result, const cpp_dec_float<Digits10, ExponentType, Allocator>& val)
|
||||
{
|
||||
*result = val.extract_long_double();
|
||||
}
|
||||
template <unsigned Digits10, class ExponentType, class Allocator>
|
||||
inline void eval_convert_to(double* result, const cpp_dec_float<Digits10, ExponentType, Allocator>& val)
|
||||
{
|
||||
*result = val.extract_double();
|
||||
}
|
||||
|
||||
//
|
||||
// Non member function support:
|
||||
|
||||
Reference in New Issue
Block a user