Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80112 - in sandbox/big_number: boost/multiprecision boost/multiprecision/detail libs/multiprecision/test libs/multiprecision/test/compile_fail libs/multiprecision/test/math
From: john_at_[hidden]
Date: 2012-08-21 10:42:18


Author: johnmaddock
Date: 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
New Revision: 80112
URL: http://svn.boost.org/trac/boost/changeset/80112

Log:
Add more explicit constructors and tests for them.
Centralise digits10 to digits2 conversions.
Added:
   sandbox/big_number/boost/multiprecision/detail/digits.hpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_01.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_1.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_02.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_2.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_03.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_3.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_04.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_4.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_05.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_5.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_06.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_6.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_07.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_7.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_08.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_8.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_09.cpp
      - copied unchanged from r80058, /sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_9.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_49.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_50.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_51.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_52.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_53.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_54.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_55.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_56.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_57.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_58.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/test_cpp_dec_float_conv.cpp (contents, props changed)
   sandbox/big_number/libs/multiprecision/test/test_cpp_int_conv.cpp (contents, props changed)
Removed:
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_1.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_2.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_3.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_4.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_5.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_6.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_7.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_8.cpp
   sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_9.cpp
Text files modified:
   sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp | 28 ++++++++
   sandbox/big_number/boost/multiprecision/cpp_int.hpp | 76 +++++++++++++++++++++++++
   sandbox/big_number/boost/multiprecision/gmp.hpp | 79 +++++++++++++------------
   sandbox/big_number/boost/multiprecision/mpfr.hpp | 121 +++++++++++++++++++++++++--------------
   sandbox/big_number/boost/multiprecision/number.hpp | 22 +-----
   sandbox/big_number/libs/multiprecision/test/Jamfile.v2 | 4
   sandbox/big_number/libs/multiprecision/test/math/test_bessel_j.cpp | 2
   sandbox/big_number/libs/multiprecision/test/math/test_bessel_y.cpp | 2
   sandbox/big_number/libs/multiprecision/test/math/test_erf.cpp | 2
   sandbox/big_number/libs/multiprecision/test/math/test_gamma.cpp | 2
   sandbox/big_number/libs/multiprecision/test/math/test_legendre.cpp | 2
   sandbox/big_number/libs/multiprecision/test/test_cos.cpp | 2
   sandbox/big_number/libs/multiprecision/test/test_cpp_int.cpp | 6
   sandbox/big_number/libs/multiprecision/test/test_generic_conv.cpp | 32 +++++-----
   sandbox/big_number/libs/multiprecision/test/test_mpfr_conversions.cpp | 18 +++++
   15 files changed, 269 insertions(+), 129 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_dec_float.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -192,15 +192,25 @@
       prec_elem(f.prec_elem) { }
 
    template <unsigned D>
- cpp_dec_float(const cpp_dec_float<D>& f) BOOST_NOEXCEPT :
+ cpp_dec_float(const cpp_dec_float<D>& f, typename enable_if_c<D <= Digits10>::type* = 0) BOOST_NOEXCEPT :
+ data(),
+ exp (f.exp),
+ neg (f.neg),
+ fpclass (static_cast<fpclass_type>(static_cast<int>(f.fpclass))),
+ prec_elem(cpp_dec_float_elem_number)
+ {
+ std::copy(f.data.begin(), f.data.begin() + f.prec_elem, data.begin());
+ }
+ template <unsigned D>
+ explicit cpp_dec_float(const cpp_dec_float<D>& f, typename disable_if_c<D <= Digits10>::type* = 0) BOOST_NOEXCEPT :
+ data(),
       exp (f.exp),
       neg (f.neg),
       fpclass (static_cast<fpclass_type>(static_cast<int>(f.fpclass))),
       prec_elem(cpp_dec_float_elem_number)
    {
       // TODO: this doesn't round!
- std::copy(f.data.begin(), f.data.begin() + (std::min)(f.prec_elem, prec_elem), data.begin());
- precision((std::min)(f.prec_elem, prec_elem));
+ std::copy(f.data.begin(), f.data.begin() + prec_elem, data.begin());
    }
 
    template <class F>
@@ -2855,6 +2865,18 @@
 typedef number<cpp_dec_float<50> > cpp_dec_float_50;
 typedef number<cpp_dec_float<100> > cpp_dec_float_100;
 
+#ifdef BOOST_NO_SFINAE_EXPR
+
+namespace detail{
+
+template<unsigned D1, unsigned D2>
+struct is_explicitly_convertible<cpp_dec_float<D1>, cpp_dec_float<D2> > : public mpl::true_ {};
+
+}
+
+#endif
+
+
 }}
 
 namespace std

Modified: sandbox/big_number/boost/multiprecision/cpp_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/cpp_int.hpp (original)
+++ sandbox/big_number/boost/multiprecision/cpp_int.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -683,6 +683,10 @@
 #ifndef BOOST_NO_RVALUE_REFERENCES
    BOOST_FORCEINLINE BOOST_CONSTEXPR cpp_int_backend(cpp_int_backend&& o) BOOST_NOEXCEPT : base_type(static_cast<base_type&&>(o)) {}
 #endif
+ //
+ // These are templates, so that only args that are *exactly* the types specified are allowed, and conversions
+ // are not considered. Without this, conversions may be ambiguous.
+ //
    template <class LT>
    BOOST_FORCEINLINE BOOST_CONSTEXPR cpp_int_backend(LT i, typename enable_if<is_same<LT, limb_type> >::type const* = 0)BOOST_NOEXCEPT
       : base_type(i) {}
@@ -697,6 +701,67 @@
    BOOST_FORCEINLINE BOOST_CONSTEXPR cpp_int_backend(SLT i, typename enable_if<is_same<SLT, signed_double_limb_type> >::type const* = 0)BOOST_NOEXCEPT
       : base_type(i) {}
 #endif
+
+ template <unsigned MinBits2, bool Signed2, class Allocator2>
+ cpp_int_backend(const cpp_int_backend<MinBits2, Signed2, Allocator2, true>& other)
+ : base_type()
+ {
+ *this = static_cast<
+ typename detail::canonical<
+ typename cpp_int_backend<MinBits2, Signed2, Allocator2, true>::local_limb_type,
+ cpp_int_backend<MinBits, Signed, Allocator, false>
+ >::type
+ >(*other.limbs());
+ this->sign(other.sign());
+ }
+ template <unsigned MinBits2, bool Signed2, class Allocator2>
+ cpp_int_backend& operator=(const cpp_int_backend<MinBits2, Signed2, Allocator2, true>& other)
+ {
+ *this = static_cast<
+ typename detail::canonical<
+ typename cpp_int_backend<MinBits2, Signed2, Allocator2, true>::local_limb_type,
+ cpp_int_backend<MinBits, Signed, Allocator, false>
+ >::type
+ >(*other.limbs());
+ this->sign(other.sign());
+ return *this;
+ }
+
+ template <unsigned MinBits2, bool Signed2, class Allocator2>
+ cpp_int_backend(const cpp_int_backend<MinBits2, Signed2, Allocator2, false>& other,
+ typename enable_if_c<
+ (Signed || !Signed2)
+ && (!is_void<Allocator>::value || (is_void<Allocator2>::value && (MinBits >= MinBits2)))
+ >::type* = 0)
+ : base_type()
+ {
+ this->resize(other.size());
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+ this->sign(other.sign());
+ }
+
+ template <unsigned MinBits2, bool Signed2, class Allocator2>
+ explicit cpp_int_backend(const cpp_int_backend<MinBits2, Signed2, Allocator2, false>& other,
+ typename disable_if_c<
+ (Signed || !Signed2)
+ && (!is_void<Allocator>::value || (is_void<Allocator2>::value && (MinBits >= MinBits2)))
+ >::type* = 0)
+ : base_type()
+ {
+ this->resize(other.size());
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+ this->sign(other.sign());
+ }
+
+ template <unsigned MinBits2, bool Signed2, class Allocator2>
+ cpp_int_backend& operator=(const cpp_int_backend<MinBits2, Signed2, Allocator2, false>& other)
+ {
+ this->resize(other.size());
+ std::copy(other.limbs(), other.limbs() + (std::min)(other.size(), this->size()), this->limbs());
+ this->sign(other.sign());
+ return *this;
+ }
+
    BOOST_FORCEINLINE cpp_int_backend& operator = (const cpp_int_backend& o) BOOST_NOEXCEPT_IF(boost::is_void<Allocator>::value)
    {
       this->assign(o);
@@ -2881,6 +2946,17 @@
 #pragma warning(pop)
 #endif
 
+#ifdef BOOST_NO_SFINAE_EXPR
+
+namespace detail{
+
+template<unsigned MinBits, bool Signed, class Allocator, bool trivial, unsigned MinBits2, bool Signed2, class Allocator2, bool trivial2>
+struct is_explicitly_convertible<cpp_int_backend<MinBits, Signed, Allocator, trivial>, cpp_int_backend<MinBits2, Signed2, Allocator2, trivial2> > : public mpl::true_ {};
+
+}
+
+#endif
+
 }} // namespaces
 
 #include <boost/multiprecision/detail/cpp_int_trivial_ops.hpp>

Added: sandbox/big_number/boost/multiprecision/detail/digits.hpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/boost/multiprecision/detail/digits.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+
+#ifndef BOOST_MP_DIGITS_HPP
+#define BOOST_MP_DIGITS_HPP
+
+namespace boost{ namespace multiprecision{ namespace detail{
+
+inline unsigned long digits10_2_2(unsigned long d10)
+{
+ return (d10 * 1000uL) / 301uL + ((d10 * 1000uL) % 301 ? 2u : 1u);
+}
+
+inline unsigned long digits2_2_10(unsigned long d2)
+{
+ return (d2 * 301uL) / 1000uL;
+}
+
+}}} // namespaces
+
+#endif

Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -9,6 +9,7 @@
 #include <boost/multiprecision/number.hpp>
 #include <boost/multiprecision/detail/integer_ops.hpp>
 #include <boost/multiprecision/detail/big_lanczos.hpp>
+#include <boost/multiprecision/detail/digits.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/lexical_cast.hpp>
@@ -67,7 +68,7 @@
       // to get the right value, but if it's then used in further calculations
       // things go badly wrong!!
       //
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(o.m_data[0]._mp_d)
          mpf_set(m_data, o.m_data);
    }
@@ -81,7 +82,7 @@
    gmp_float_imp& operator = (const gmp_float_imp& o)
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(o.m_data[0]._mp_d)
          mpf_set(m_data, o.m_data);
       return *this;
@@ -96,11 +97,11 @@
    gmp_float_imp& operator = (unsigned long long i)
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpf_t t;
- mpf_init2(t, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(t, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpf_set_ui(m_data, 0);
       while(i)
       {
@@ -118,7 +119,7 @@
    {
       BOOST_MP_USING_ABS
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       bool neg = i < 0;
       *this = static_cast<unsigned long long>(abs(i));
       if(neg)
@@ -128,21 +129,21 @@
    gmp_float_imp& operator = (unsigned long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpf_set_ui(m_data, i);
       return *this;
    }
    gmp_float_imp& operator = (long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpf_set_si(m_data, i);
       return *this;
    }
    gmp_float_imp& operator = (double d) BOOST_NOEXCEPT
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpf_set_d(m_data, d);
       return *this;
    }
@@ -153,7 +154,7 @@
       using std::floor;
 
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
 
       if (a == 0) {
          mpf_set_si(m_data, 0);
@@ -198,7 +199,7 @@
    gmp_float_imp& operator = (const char* s)
    {
       if(m_data[0]._mp_d == 0)
- mpf_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(0 != mpf_set_str(m_data, s, 10))
          BOOST_THROW_EXCEPTION(std::runtime_error(std::string("The string \"") + s + std::string("\"could not be interpreted as a valid floating point number.")));
       return *this;
@@ -365,7 +366,7 @@
 {
    gmp_float()
    {
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
    }
    gmp_float(const gmp_float& o) : detail::gmp_float_imp<digits10>(o) {}
    template <unsigned D>
@@ -376,17 +377,17 @@
    gmp_float(const gmp_rational& o);
    gmp_float(const mpf_t val)
    {
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set(this->m_data, val);
    }
    gmp_float(const mpz_t val)
    {
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set_z(this->m_data, val);
    }
    gmp_float(const mpq_t val)
    {
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set_q(this->m_data, val);
    }
 #ifndef BOOST_NO_RVALUE_REFERENCES
@@ -411,21 +412,21 @@
    gmp_float& operator=(const mpf_t val) BOOST_NOEXCEPT
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set(this->m_data, val);
       return *this;
    }
    gmp_float& operator=(const mpz_t val) BOOST_NOEXCEPT
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set_z(this->m_data, val);
       return *this;
    }
    gmp_float& operator=(const mpq_t val) BOOST_NOEXCEPT
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set_q(this->m_data, val);
       return *this;
    }
@@ -442,21 +443,21 @@
 {
    gmp_float()
    {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
    }
    gmp_float(const mpf_t val)
    {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set(this->m_data, val);
    }
    gmp_float(const mpz_t val)
    {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set_z(this->m_data, val);
    }
    gmp_float(const mpq_t val)
    {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set_q(this->m_data, val);
    }
    gmp_float(const gmp_float& o) : detail::gmp_float_imp<0>(o) {}
@@ -473,7 +474,7 @@
    gmp_float(const gmp_rational& o);
    gmp_float(const gmp_float& o, unsigned digits10)
    {
- mpf_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpf_set(this->m_data, o.data());
    }
 
@@ -508,21 +509,21 @@
    gmp_float& operator=(const mpf_t val)
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set(this->m_data, val);
       return *this;
    }
    gmp_float& operator=(const mpz_t val)
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set_z(this->m_data, val);
       return *this;
    }
    gmp_float& operator=(const mpq_t val)
    {
       if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpf_set_q(this->m_data, val);
       return *this;
    }
@@ -542,11 +543,11 @@
    }
    unsigned precision()const BOOST_NOEXCEPT
    {
- return (mpf_get_prec(this->m_data) * 301L) / 1000 - 1;
+ return multiprecision::detail::digits2_2_10(mpf_get_prec(this->m_data));
    }
    void precision(unsigned digits10) BOOST_NOEXCEPT
    {
- mpf_set_prec(this->m_data, ((digits10 + 1) * 1000L) / 301);
+ mpf_set_prec(this->m_data, multiprecision::detail::digits10_2_2(digits10));
    }
 };
 
@@ -2008,26 +2009,26 @@
 template <unsigned D>
 inline gmp_float<Digits10>::gmp_float(const gmp_float<D>& o, typename enable_if_c<D <= Digits10>::type*)
 {
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set(this->m_data, o.data());
 }
 template <unsigned Digits10>
 template <unsigned D>
 inline gmp_float<Digits10>::gmp_float(const gmp_float<D>& o, typename disable_if_c<D <= Digits10>::type*)
 {
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set(this->m_data, o.data());
 }
 template <unsigned Digits10>
 inline gmp_float<Digits10>::gmp_float(const gmp_int& o)
 {
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set_z(this->data(), o.data());
 }
 template <unsigned Digits10>
 inline gmp_float<Digits10>::gmp_float(const gmp_rational& o)
 {
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set_q(this->data(), o.data());
 }
 template <unsigned Digits10>
@@ -2035,7 +2036,7 @@
 inline gmp_float<Digits10>& gmp_float<Digits10>::operator=(const gmp_float<D>& o)
 {
    if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set(this->m_data, o.data());
    return *this;
 }
@@ -2043,7 +2044,7 @@
 inline gmp_float<Digits10>& gmp_float<Digits10>::operator=(const gmp_int& o)
 {
    if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set_z(this->data(), o.data());
    return *this;
 }
@@ -2051,31 +2052,31 @@
 inline gmp_float<Digits10>& gmp_float<Digits10>::operator=(const gmp_rational& o)
 {
    if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, (((Digits10 ? Digits10 : this->get_default_precision()) + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(Digits10 ? Digits10 : this->get_default_precision()));
    mpf_set_q(this->data(), o.data());
    return *this;
 }
 inline gmp_float<0>::gmp_float(const gmp_int& o)
 {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
    mpf_set_z(this->data(), o.data());
 }
 inline gmp_float<0>::gmp_float(const gmp_rational& o)
 {
- mpf_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
    mpf_set_q(this->data(), o.data());
 }
 inline gmp_float<0>& gmp_float<0>::operator=(const gmp_int& o)
 {
    if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((this->get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(this->get_default_precision()));
    mpf_set_z(this->data(), o.data());
    return *this;
 }
 inline gmp_float<0>& gmp_float<0>::operator=(const gmp_rational& o)
 {
    if(this->m_data[0]._mp_d == 0)
- mpf_init2(this->m_data, ((this->get_default_precision() + 1) * 1000L) / 301L);
+ mpf_init2(this->m_data, multiprecision::detail::digits10_2_2(this->get_default_precision()));
    mpf_set_q(this->data(), o.data());
    return *this;
 }
@@ -2185,7 +2186,7 @@
    {
       return -(max)();
    }
- BOOST_STATIC_CONSTEXPR int digits = static_cast<int>(((Digits10 + 1) * 1000L) / 301L);
+ BOOST_STATIC_CONSTEXPR int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301L ? 2 : 1));
    BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
    // Have to allow for a possible extra limb inside the gmp data structure:
    BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 2 + ((GMP_LIMB_BITS * 301L) / 1000L);

Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -12,6 +12,7 @@
 #include <boost/cstdint.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/multiprecision/detail/big_lanczos.hpp>
+#include <boost/multiprecision/detail/digits.hpp>
 #include <mpfr.h>
 #include <cmath>
 #include <algorithm>
@@ -46,7 +47,7 @@
 
    mpfr_float_imp(const mpfr_float_imp& o)
    {
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(o.m_data[0]._mpfr_d)
          mpfr_set(m_data, o.m_data, GMP_RNDN);
    }
@@ -60,7 +61,7 @@
    mpfr_float_imp& operator = (const mpfr_float_imp& o) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(o.m_data[0]._mpfr_d)
          mpfr_set(m_data, o.m_data, GMP_RNDN);
       return *this;
@@ -76,14 +77,14 @@
    mpfr_float_imp& operator = (unsigned long long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_uj(m_data, i, GMP_RNDN);
       return *this;
    }
    mpfr_float_imp& operator = (long long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_sj(m_data, i, GMP_RNDN);
       return *this;
    }
@@ -91,11 +92,11 @@
    mpfr_float_imp& operator = (unsigned long long i)
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpfr_t t;
- mpfr_init2(t, (std::max)(static_cast<unsigned>(std::numeric_limits<unsigned long long>::digits), static_cast<unsigned>(((digits10 + 1) * 1000L) / 301L)));
+ mpfr_init2(t, (std::max)(static_cast<unsigned>(std::numeric_limits<unsigned long long>::digits), static_cast<unsigned>(multiprecision::detail::digits10_2_2(digits10))));
       mpfr_set_ui(m_data, 0, GMP_RNDN);
       while(i)
       {
@@ -113,7 +114,7 @@
    {
       BOOST_MP_USING_ABS
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       bool neg = i < 0;
       *this = static_cast<unsigned long long>(abs(i));
       if(neg)
@@ -124,35 +125,35 @@
    mpfr_float_imp& operator = (unsigned long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_ui(m_data, i, GMP_RNDN);
       return *this;
    }
    mpfr_float_imp& operator = (long i) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_si(m_data, i, GMP_RNDN);
       return *this;
    }
    mpfr_float_imp& operator = (double d) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_d(m_data, d, GMP_RNDN);
       return *this;
    }
    mpfr_float_imp& operator = (long double a) BOOST_NOEXCEPT
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       mpfr_set_ld(m_data, a, GMP_RNDN);
       return *this;
    }
    mpfr_float_imp& operator = (const char* s)
    {
       if(m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, (((digits10 ? digits10 : get_default_precision()) + 1) * 1000L) / 301L);
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : get_default_precision()));
       if(mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
       {
          BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
@@ -328,52 +329,64 @@
 {
    mpfr_float_backend()
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
    }
    mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10>(o) {}
 #ifndef BOOST_NO_RVALUE_REFERENCES
    mpfr_float_backend(mpfr_float_backend&& o) : detail::mpfr_float_imp<digits10>(static_cast<detail::mpfr_float_imp<digits10>&&>(o)) {}
 #endif
    template <unsigned D>
- mpfr_float_backend(const mpfr_float_backend<D>& val)
+ mpfr_float_backend(const mpfr_float_backend<D>& val, typename enable_if_c<D <= digits10>::type* = 0)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set(this->m_data, val.data(), GMP_RNDN);
    }
    template <unsigned D>
- mpfr_float_backend(const gmp_float<D>& val)
+ explicit mpfr_float_backend(const mpfr_float_backend<D>& val, typename disable_if_c<D <= digits10>::type* = 0)
+ {
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
+ }
+ template <unsigned D>
+ mpfr_float_backend(const gmp_float<D>& val, typename enable_if_c<D <= digits10>::type* = 0)
+ {
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
+ }
+ template <unsigned D>
+ mpfr_float_backend(const gmp_float<D>& val, typename disable_if_c<D <= digits10>::type* = 0)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
    }
    mpfr_float_backend(const gmp_int& val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
    }
    mpfr_float_backend(const gmp_rational& val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
    }
- mpfr_float_backend(mpfr_t val)
+ mpfr_float_backend(const mpfr_t val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpf_t val)
+ mpfr_float_backend(const mpf_t val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_f(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpz_t val)
+ mpfr_float_backend(const mpz_t val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_z(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpq_t val)
+ mpfr_float_backend(const mpq_t val)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       mpfr_set_q(this->m_data, val, GMP_RNDN);
    }
    mpfr_float_backend& operator=(const mpfr_float_backend& o)
@@ -414,6 +427,7 @@
       mpfr_set_q(this->m_data, val, GMP_RNDN);
       return *this;
    }
+ // We don't change our precision here, this is a fixed precision type:
    template <unsigned D>
    mpfr_float_backend& operator=(const mpfr_float_backend<D>& val) BOOST_NOEXCEPT
    {
@@ -443,26 +457,26 @@
 {
    mpfr_float_backend()
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
    }
- mpfr_float_backend(mpfr_t val)
+ mpfr_float_backend(const mpfr_t val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, mpfr_get_prec(val));
       mpfr_set(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpf_t val)
+ mpfr_float_backend(const mpf_t val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, mpf_get_prec(val));
       mpfr_set_f(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpz_t val)
+ mpfr_float_backend(const mpz_t val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpfr_set_z(this->m_data, val, GMP_RNDN);
    }
- mpfr_float_backend(mpq_t val)
+ mpfr_float_backend(const mpq_t val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpfr_set_q(this->m_data, val, GMP_RNDN);
    }
    mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0>(o) {}
@@ -471,29 +485,29 @@
 #endif
    mpfr_float_backend(const mpfr_float_backend& o, unsigned digits10)
    {
- mpfr_init2(this->m_data, ((digits10 + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
       *this = o;
    }
    template <unsigned D>
    mpfr_float_backend(const mpfr_float_backend<D>& val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, mpfr_get_prec(val.data()));
       mpfr_set(this->m_data, val.data(), GMP_RNDN);
    }
    template <unsigned D>
    mpfr_float_backend(const gmp_float<D>& val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, mpf_get_prec(val.data()));
       mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
    }
    mpfr_float_backend(const gmp_int& val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
    }
    mpfr_float_backend(const gmp_rational& val)
    {
- mpfr_init2(this->m_data, ((get_default_precision() + 1) * 1000L) / 301L);
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
       mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
    }
 
@@ -517,11 +531,13 @@
    }
    mpfr_float_backend& operator=(const mpfr_t val) BOOST_NOEXCEPT
    {
+ mpfr_set_prec(this->m_data, mpfr_get_prec(val));
       mpfr_set(this->m_data, val, GMP_RNDN);
       return *this;
    }
    mpfr_float_backend& operator=(const mpf_t val) BOOST_NOEXCEPT
    {
+ mpfr_set_prec(this->m_data, mpf_get_prec(val));
       mpfr_set_f(this->m_data, val, GMP_RNDN);
       return *this;
    }
@@ -538,12 +554,14 @@
    template <unsigned D>
    mpfr_float_backend& operator=(const mpfr_float_backend<D>& val) BOOST_NOEXCEPT
    {
+ mpfr_set_prec(this->m_data, mpfr_get_prec(val.data()));
       mpfr_set(this->m_data, val.data(), GMP_RNDN);
       return *this;
    }
    template <unsigned D>
    mpfr_float_backend& operator=(const gmp_float<D>& val) BOOST_NOEXCEPT
    {
+ mpfr_set_prec(this->m_data, mpf_get_prec(val.data()));
       mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
       return *this;
    }
@@ -567,11 +585,11 @@
    }
    unsigned precision()const BOOST_NOEXCEPT
    {
- return mpfr_get_prec(this->m_data) * 301L / 1000 - 1;
+ return multiprecision::detail::digits2_2_10(mpfr_get_prec(this->m_data));
    }
    void precision(unsigned digits10) BOOST_NOEXCEPT
    {
- mpfr_set_prec(this->m_data, (digits10 + 1) * 1000L / 301);
+ mpfr_set_prec(this->m_data, multiprecision::detail::digits2_2_10((digits10)));
    }
 };
 
@@ -1051,6 +1069,21 @@
 
 } // namespace backends
 
+#ifdef BOOST_NO_SFINAE_EXPR
+
+namespace detail{
+
+template<unsigned D1, unsigned D2>
+struct is_explicitly_convertible<backends::mpfr_float_backend<D1>, backends::mpfr_float_backend<D2> > : public mpl::true_ {};
+
+}
+
+#endif
+
+template<>
+struct number_category<typename detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point>{};
+
+
 using boost::multiprecision::backends::mpfr_float_backend;
 
 typedef number<mpfr_float_backend<50> > mpfr_float_50;
@@ -1119,7 +1152,7 @@
    {
       return -(max)();
    }
- BOOST_STATIC_CONSTEXPR int digits = static_cast<int>(((Digits10 + 1) * 1000L) / 301L);
+ BOOST_STATIC_CONSTEXPR int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
    BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
    // Is this really correct???
    BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 2;

Modified: sandbox/big_number/boost/multiprecision/number.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/number.hpp (original)
+++ sandbox/big_number/boost/multiprecision/number.hpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -99,9 +99,8 @@
       : m_backend(val.backend()) {}
 
    template <class Other, bool ET>
- number(const number<Other, ET>& val, typename enable_if_c<
- (!detail::is_explicitly_convertible<Other, Backend>::value
- && !detail::is_restricted_conversion<Other, Backend>::value)
+ explicit number(const number<Other, ET>& val, typename enable_if_c<
+ (!detail::is_explicitly_convertible<Other, Backend>::value)
>::type* = 0)
    {
       //
@@ -116,17 +115,6 @@
>::type* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = std::declval<Other>()))
       : m_backend(val.backend()) {}
 
- template <class Other, bool ET>
- explicit number(const number<Other, ET>& val, typename enable_if_c<
- (!detail::is_explicitly_convertible<Other, Backend>::value
- && detail::is_restricted_conversion<Other, Backend>::value)
- >::type* = 0)
- {
- //
- // Attempt a generic interconvertion:
- //
- detail::generic_interconvert(backend(), val.backend(), number_category<Backend>(), number_category<Other>());
- }
    template <class V>
    BOOST_FORCEINLINE number(V v1, V v2, typename enable_if<mpl::or_<boost::is_arithmetic<V>, is_same<std::string, V>, is_convertible<V, const char*> > >::type* = 0)
    {
@@ -210,7 +198,7 @@
       return *this;
    }
    */
-
+/*
    template <class Other>
    typename disable_if<detail::is_explicitly_convertible<Other, Backend>, number<Backend, ExpressionTemplates>& >::type
       operator=(const number<Other>& v)
@@ -220,7 +208,7 @@
       //
       detail::generic_interconvert(backend(), v.backend(), number_category<Backend>(), number_category<Other>());
       return *this;
- }
+ }*/
    template <class Other>
    typename disable_if<is_convertible<Other, Backend>, number<Backend, ExpressionTemplates>& >::type
       assign(const number<Other>& v)
@@ -672,7 +660,7 @@
       // create a temporary result and assign it to *this:
       typedef typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type temp_type;
       temp_type t(e);
- *this = t;
+ this->assign(t);
    }
 
 

Modified: sandbox/big_number/libs/multiprecision/test/Jamfile.v2
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/Jamfile.v2 (original)
+++ sandbox/big_number/libs/multiprecision/test/Jamfile.v2 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -738,6 +738,7 @@
         : # requirements
          [ check-target-builds ../config//has_tommath : : <build>no ] ;
 run ../example/floating_point_examples.cpp : : : <toolset>gcc:<cxxflags>-std=c++0x ;
+run test_cpp_int_conv.cpp ;
 
 compile include_test/mpfr_include_test.cpp
               : # requirements
@@ -804,7 +805,8 @@
 {
    compile-fail $(source)
    :
- [ check-target-builds ../config//has_gmp : <define>TEST_GMP : ]
+ [ check-target-builds ../config//has_gmp : <define>TEST_GMP : ]
+ [ check-target-builds ../config//has_mpfr : <define>TEST_MPFR : ]
    ;
 }
 

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_1.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_1.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,17 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-void foo(cpp_int i)
-{
-}
-
-int main()
-{
- foo(2.3); // conversion from float is explicit
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_2.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_2.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i == 2.3;
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_3.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_3.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i != 2.3;
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_4.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_4.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i <= 2.3;
-}

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_49.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_49.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifdef TEST_MPFR
+
+#include <boost/multiprecision/mpfr.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ mpfr_float_100 f(2);
+ mpfr_float_50 f2;
+ f2 = f;
+}
+
+#else
+
+#error "Nothing to test without GMP!"
+
+#endif

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_5.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_5.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i >= 2.3;
-}

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_50.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_50.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifdef TEST_MPFR
+
+#include <boost/multiprecision/mpfr.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ mpfr_float_100 f(2);
+ mpfr_float_50 f2 = f;
+}
+
+#else
+
+#error "Nothing to test without GMP!"
+
+#endif

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_51.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_51.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_dec_float_100 f(2);
+ cpp_dec_float_50 f2 = f;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_52.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_52.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,16 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_dec_float_100 f(2);
+ cpp_dec_float_50 f2;
+ f2 = f;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_53.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_53.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ int256_t i = 3;
+ int128_t j = i;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_54.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_54.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,16 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ int256_t i = 3;
+ int128_t j;
+ j = i;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_55.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_55.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,16 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ int256_t i = 3;
+ uint256_t j;
+ j = i;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_56.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_56.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ int256_t i = 3;
+ uint256_t j = i;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_57.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_57.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,15 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_int i = 3;
+ int256_t j = i;
+}
+

Added: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_58.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_58.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,16 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_int i = 3;
+ int256_t j;
+ j = i;
+}
+

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_6.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_6.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i > 2.3;
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_7.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_7.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i < 2.3;
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_8.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_8.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i = 2.3;
-}

Deleted: sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_9.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/compile_fail/conv_fail_9.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
+++ (empty file)
@@ -1,14 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright 2012 John Maddock. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/multiprecision/cpp_int.hpp>
-
-using namespace boost::multiprecision;
-
-int main()
-{
- cpp_int i = 2;
- i += 2.3;
-}

Modified: sandbox/big_number/libs/multiprecision/test/math/test_bessel_j.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/math/test_bessel_j.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/math/test_bessel_j.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -87,7 +87,7 @@
       ".*", // platform
       ".*", // test type(s)
       ".*JN.*Integer.*", // test data group
- ".*", 40000, 10000); // test function
+ ".*", 50000, 15000); // test function
    add_expected_result(
       ".*", // compiler
       ".*", // stdlib

Modified: sandbox/big_number/libs/multiprecision/test/math/test_bessel_y.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/math/test_bessel_y.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/math/test_bessel_y.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -107,7 +107,7 @@
       ".*", // platform
       ".*", // test type(s)
       ".*", // test data group
- ".*", 80, 40); // test function
+ ".*", 150, 60); // test function
    //
    // Finish off by printing out the compiler/stdlib/platform names,
    // we do this to make it easier to mark up expected error rates.

Modified: sandbox/big_number/libs/multiprecision/test/math/test_erf.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/math/test_erf.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/math/test_erf.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -75,7 +75,7 @@
       ".*", // platform
       ".*", // test type(s)
       "Inverse Erf.*", // test data group
- "boost::math::erfc?_inv", 35, 20); // test function
+ "boost::math::erfc?_inv", 60, 20); // test function
    //
    // Finish off by printing out the compiler/stdlib/platform names,
    // we do this to make it easier to mark up expected error rates.

Modified: sandbox/big_number/libs/multiprecision/test/math/test_gamma.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/math/test_gamma.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/math/test_gamma.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -68,7 +68,7 @@
       ".*", // platform
       ".*", // test type(s)
       "factorials", // test data group
- "boost::math::lgamma", 80, 40); // test function
+ "boost::math::lgamma", 750, 100); // test function
    add_expected_result(
       ".*", // compiler
       ".*", // stdlib

Modified: sandbox/big_number/libs/multiprecision/test/math/test_legendre.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/math/test_legendre.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/math/test_legendre.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -54,7 +54,7 @@
       ".*", // platform
       ".*", // test type(s)
       ".*", // test data group
- ".*", 5000, 500); // test function
+ ".*", 6000, 500); // test function
    //
    // Finish off by printing out the compiler/stdlib/platform names,
    // we do this to make it easier to mark up expected error rates.

Modified: sandbox/big_number/libs/multiprecision/test/test_cos.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_cos.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_cos.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -243,7 +243,7 @@
          max_err = err;
    }
    std::cout << "Max error was: " << max_err << std::endl;
- BOOST_TEST(max_err < 500);
+ BOOST_TEST(max_err < 750);
 
    //
    // Test with some exact binary values as input - this tests our code

Added: sandbox/big_number/libs/multiprecision/test/test_cpp_dec_float_conv.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/test_cpp_dec_float_conv.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+//
+
+#ifdef _MSC_VER
+# define _SCL_SECURE_NO_WARNINGS
+#endif
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/array.hpp>
+#include "test.hpp"
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+
+int main()
+{
+ using namespace boost::multiprecision;
+ //
+ // Test interconversions between different precisions:
+ //
+ cpp_dec_float_50 f1(2);
+ cpp_dec_float_100 f2(3);
+
+ cpp_dec_float_100 f3 = f1; // implicit conversion OK
+ BOOST_TEST(f3 == 2);
+ cpp_dec_float_50 f4(f2); // explicit conversion OK
+ BOOST_TEST(f4 == 3);
+
+ f2 = f1;
+ BOOST_TEST(f2 == 2);
+ f2 = 4;
+ f1 = static_cast<cpp_dec_float_50>(f2);
+ BOOST_TEST(f1 == 4);
+
+
+ return boost::report_errors();
+}
+
+
+

Modified: sandbox/big_number/libs/multiprecision/test/test_cpp_int.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_cpp_int.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_cpp_int.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -281,9 +281,9 @@
          // also don't test for modulo types, as these may give a diffferent result from arbitrary
          // precision types:
          BOOST_CHECK_EQUAL(mpz_int(pow(d, ui % 19)).str(), test_type(pow(d1, ui % 19)).str());
- BOOST_CHECK_EQUAL(mpz_int(powm(a, b, c)).str(), test_type(powm(a, b, c)).str());
- BOOST_CHECK_EQUAL(mpz_int(powm(a, b, ui)).str(), test_type(powm(a, b, ui)).str());
- BOOST_CHECK_EQUAL(mpz_int(powm(a, ui, c)).str(), test_type(powm(a, ui, c)).str());
+ BOOST_CHECK_EQUAL(mpz_int(powm(a, b, c)).str(), test_type(powm(a1, b1, c1)).str());
+ BOOST_CHECK_EQUAL(mpz_int(powm(a, b, ui)).str(), test_type(powm(a1, b1, ui)).str());
+ BOOST_CHECK_EQUAL(mpz_int(powm(a, ui, c)).str(), test_type(powm(a1, ui, c1)).str());
       }
 
       if(last_error_count != (unsigned)boost::detail::test_errors())

Added: sandbox/big_number/libs/multiprecision/test/test_cpp_int_conv.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/test_cpp_int_conv.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -0,0 +1,55 @@
+///////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
+//
+
+#ifdef _MSC_VER
+# define _SCL_SECURE_NO_WARNINGS
+#endif
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/array.hpp>
+#include "test.hpp"
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+int main()
+{
+ using namespace boost::multiprecision;
+ //
+ // Test interconversions between different precisions:
+ //
+ cpp_int i1(2);
+ int128_t i2(3);
+ int256_t i3(4);
+ number<cpp_int_backend<32, true, void> > i4(5);
+
+ i1 = i3;
+ BOOST_TEST(i1 == 4);
+ i1 = i4;
+ BOOST_TEST(i1 == 5);
+
+ i3 = -1234567;
+ i4 = -5677334;
+ i1 = i3;
+ BOOST_TEST(i1 == -1234567);
+ i1 = i4;
+ BOOST_TEST(i1 == -5677334);
+
+ i3 = i2;
+ BOOST_TEST(i3 == 3);
+
+ i3 = -1234567;
+
+ uint128_t i5(i3);
+ BOOST_TEST(i5 == -1234567);
+
+ int128_t i6(i4);
+ BOOST_TEST(i6 == -5677334);
+
+ return boost::report_errors();
+}
+
+
+

Modified: sandbox/big_number/libs/multiprecision/test/test_generic_conv.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_generic_conv.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_generic_conv.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -43,16 +43,16 @@
       mpz_int z(c);
       cpp_int t(z);
       BOOST_CHECK_EQUAL(t, c);
- z = -c;
- t = -z;
+ z.assign(-c);
+ t.assign(-z);
       BOOST_CHECK_EQUAL(t, c);
 #endif
 #ifdef TEST_TOMMATH
       tom_int tom(c);
       cpp_int t2(tom);
       BOOST_CHECK_EQUAL(t2, c);
- tom = -c;
- t2 = -tom;
+ tom.assign(-c);
+ t2.assign(-tom);
       BOOST_CHECK_EQUAL(t2, c);
 #endif
       //
@@ -62,7 +62,7 @@
       dec_float_500 df(c);
       dec_float_500 df2(c.str());
       BOOST_CHECK_EQUAL(df, df2);
- df = -c;
+ df.assign(-c);
       df2 = -df2;
       BOOST_CHECK_EQUAL(df, df2);
 #ifdef TEST_GMP
@@ -70,7 +70,7 @@
       mpf_type mpf(c);
       mpf_type mpf2(c.str());
       BOOST_CHECK_EQUAL(mpf, mpf2);
- mpf = -c;
+ mpf.assign(-c);
       mpf2 = -mpf2;
       BOOST_CHECK_EQUAL(mpf, mpf2);
 #endif
@@ -79,29 +79,29 @@
       mpfr_type mpfr(c);
       mpfr_type mpfr2(c.str());
       BOOST_CHECK_EQUAL(mpfr, mpfr2);
- mpfr = -c;
+ mpfr.assign(-c);
       mpfr2 = -mpfr2;
       BOOST_CHECK_EQUAL(mpfr, mpfr2);
 #endif
       //
       // Now float to float:
       //
- df = c;
+ df.assign(c);
       df /= dec_float_500(gen());
       dec_float_500 tol("1e-500");
 #ifdef TEST_GMP
- mpf = df;
+ mpf.assign(df);
       mpf2 = static_cast<mpf_type>(df.str());
       BOOST_CHECK_EQUAL(mpf, mpf2);
- df = mpf;
+ df.assign(mpf);
       df2 = static_cast<dec_float_500>(mpf.str());
       BOOST_CHECK(fabs((df - df2) / df) < tol);
 #endif
 #ifdef TEST_MPFR
- mpfr = df;
+ mpfr.assign(df);
       mpfr2 = static_cast<mpfr_type>(df.str());
       BOOST_CHECK_EQUAL(mpfr, mpfr2);
- df = mpfr;
+ df.assign(mpfr);
       df2 = static_cast<dec_float_500>(mpfr.str());
       BOOST_CHECK(fabs((df - df2) / df) < tol);
 #endif
@@ -123,20 +123,20 @@
       // Integer to rational conversions:
       //
 #ifdef TEST_GMP
- mpq = c;
+ mpq.assign(c);
       mpq_rational mpq2 = static_cast<mpq_rational>(c.str());
       BOOST_CHECK_EQUAL(mpq, mpq2);
 #endif
 #ifdef TEST_TOMMATH
- tr = c;
+ tr.assign(c);
       tom_rational tr2 = static_cast<tom_rational>(c.str());
       BOOST_CHECK_EQUAL(tr, tr2);
 #endif
       //
       // Rational to float:
       //
- df = cppr;
- df2 = numerator(cppr);
+ df.assign(cppr);
+ df2.assign(numerator(cppr));
       df2 /= dec_float_500(denominator(cppr));
       BOOST_CHECK(fabs(df - df2) / df2 < tol);
    }

Modified: sandbox/big_number/libs/multiprecision/test/test_mpfr_conversions.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_mpfr_conversions.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_mpfr_conversions.cpp 2012-08-21 10:42:15 EDT (Tue, 21 Aug 2012)
@@ -100,6 +100,24 @@
    BOOST_TEST(mpfr_float(gf) == 2);
    BOOST_TEST(mpfr_float_50(gf) == 2);
 
+ //
+ // Conversions involving precision only:
+ //
+ mpfr_float::default_precision(30);
+ f50 = 2;
+ mpfr_float_100 f100(3);
+ mpfr_float f0a(4);
+ mpfr_float f0b(f100);
+ BOOST_TEST(f0a.precision() == 30);
+ BOOST_TEST(f0b.precision() == 100);
+ f0a = f100;
+ BOOST_TEST(f0a == 3);
+ BOOST_TEST(f0a.precision() == 100);
+
+ f100 = f50;
+ BOOST_TEST(f100 == 2);
+
+ f50 = static_cast<mpfr_float_50>(f100);
 
    return boost::report_errors();
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk