From 7c34000953f2896f97ffb37a1a9f55aaae752000 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 7 Aug 2016 19:12:03 +0100 Subject: [PATCH 1/9] Add missing qualifier to isnan call. --- test/test_arithmetic.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index a74920fc..e9c8ab7a 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -887,8 +887,8 @@ void test_float_funcs(const boost::mpl::true_&) { a = std::numeric_limits::quiet_NaN(); b = modf(a, &c); - BOOST_CHECK((isnan)(b)); - BOOST_CHECK((isnan)(c)); + BOOST_CHECK((boost::math::isnan)(b)); + BOOST_CHECK((boost::math::isnan)(c)); } a = 4; From d5edf412358564c9a757839fb28b30065079e205 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 11 Aug 2016 10:26:11 +0100 Subject: [PATCH 2/9] Disable some overloads for VC12 and earlier - for some reason the compiler can't cope with them :( --- include/boost/multiprecision/detail/default_ops.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/multiprecision/detail/default_ops.hpp b/include/boost/multiprecision/detail/default_ops.hpp index 1ebd6320..f01564e1 100644 --- a/include/boost/multiprecision/detail/default_ops.hpp +++ b/include/boost/multiprecision/detail/default_ops.hpp @@ -358,6 +358,7 @@ inline void eval_multiply_default(T& t, const T& u, const T& v) eval_multiply(t, v); } } +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1900) template inline typename enable_if_c >::value && !is_convertible::value>::type eval_multiply_default(T& t, const T& u, const U& v) { @@ -376,6 +377,7 @@ inline typename enable_if_c >::value>::type e { eval_multiply(t, v, u); } +#endif template inline void eval_multiply_default(T& t, const U& u, const V& v) { @@ -456,6 +458,7 @@ inline void eval_divide_default(T& t, const T& u, const T& v) eval_divide(t, v); } } +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1900) template inline typename enable_if_c >::value && !is_convertible::value>::type eval_divide_default(T& t, const T& u, const U& v) { @@ -482,12 +485,14 @@ inline typename enable_if_c >::value && is_co T uu(u); eval_divide(t, uu, v); } +#endif template inline void eval_divide_default(T& t, const U& u, const V& v) { if(is_same::value && ((void*)&t == (void*)&v)) { - T temp(u); + T temp; + temp = u; eval_divide(temp, v); t = temp; } From 11d6776b3d8ff1444858373cc2286d47c0fc280f Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 14 Aug 2016 18:46:42 +0100 Subject: [PATCH 3/9] Change negate to negate_value to avoid gcc-4.4 error. --- test/test_arithmetic.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index e9c8ab7a..64bb46bd 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -1529,12 +1529,12 @@ inline bool check_is_nan(const Real&, const boost::mpl::false_&) return false; } template -inline Real negate(const Real& val, const boost::mpl::true_&) +inline Real negate_value(const Real& val, const boost::mpl::true_&) { return -val; } template -inline Real negate(const Real& val, const boost::mpl::false_&) +inline Real negate_value(const Real& val, const boost::mpl::false_&) { return val; } @@ -1745,14 +1745,14 @@ void test_mixed(const boost::mpl::true_&) { d = static_cast(std::numeric_limits::infinity()); BOOST_CHECK_GT(d, (std::numeric_limits::max)()); - d = static_cast(negate(std::numeric_limits::infinity(), boost::mpl::bool_::is_signed>())); - BOOST_CHECK_LT(d, negate((std::numeric_limits::max)(), boost::mpl::bool_::is_signed>())); + d = static_cast(negate_value(std::numeric_limits::infinity(), boost::mpl::bool_::is_signed>())); + BOOST_CHECK_LT(d, negate_value((std::numeric_limits::max)(), boost::mpl::bool_::is_signed>())); } if(std::numeric_limits::has_quiet_NaN && std::numeric_limits::has_quiet_NaN) { d = static_cast(std::numeric_limits::quiet_NaN()); BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); - d = static_cast(negate(std::numeric_limits::quiet_NaN(), boost::mpl::bool_::is_signed>())); + d = static_cast(negate_value(std::numeric_limits::quiet_NaN(), boost::mpl::bool_::is_signed>())); BOOST_CHECK(check_is_nan(d, boost::mpl::bool_::has_quiet_NaN>())); } } From 339818c0180d0719852b3e648b8d76f2ba02e32d Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 17 Aug 2016 18:12:41 +0100 Subject: [PATCH 4/9] Fix compiler errors when converting from cpp_int's to cpp_bin_float's As reported on the mailing list. Also adds new test case. --- include/boost/multiprecision/cpp_int/misc.hpp | 4 +- .../multiprecision/detail/default_ops.hpp | 30 +++++++++- .../detail/generic_interconvert.hpp | 17 +++--- test/Jamfile.v2 | 1 + test/test_cpp_bin_float_conv.cpp | 58 +++++++++++++++++++ 5 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 test/test_cpp_bin_float_conv.cpp diff --git a/include/boost/multiprecision/cpp_int/misc.hpp b/include/boost/multiprecision/cpp_int/misc.hpp index 7de93f24..eb2f6f3a 100644 --- a/include/boost/multiprecision/cpp_int/misc.hpp +++ b/include/boost/multiprecision/cpp_int/misc.hpp @@ -564,8 +564,8 @@ inline typename enable_if_c< *result = static_cast(*val.limbs()); if(val.isneg()) { - check_is_negative(mpl::bool_::value || boost::is_floating_point::value>()); - *result = negate_integer(*result, mpl::bool_::value || boost::is_floating_point::value>()); + check_is_negative(mpl::bool_::value || (number_category::value == number_kind_floating_point)>()); + *result = negate_integer(*result, mpl::bool_::value || (number_category::value == number_kind_floating_point)>()); } } } diff --git a/include/boost/multiprecision/detail/default_ops.hpp b/include/boost/multiprecision/detail/default_ops.hpp index f01564e1..d9fa1947 100644 --- a/include/boost/multiprecision/detail/default_ops.hpp +++ b/include/boost/multiprecision/detail/default_ops.hpp @@ -25,7 +25,25 @@ #endif -namespace boost{ namespace multiprecision{ namespace default_ops{ +namespace boost{ namespace multiprecision{ + + namespace detail { + + template + void generic_interconvert(To& to, const From& from, const mpl::int_& /*to_type*/, const mpl::int_& /*from_type*/); + template + void generic_interconvert(To& to, const From& from, const mpl::int_& /*to_type*/, const mpl::int_& /*from_type*/); + template + void generic_interconvert(To& to, const From& from, const mpl::int_& /*to_type*/, const mpl::int_& /*from_type*/); + template + void generic_interconvert(To& to, const From& from, const mpl::int_& /*to_type*/, const mpl::int_& /*from_type*/); + template + void generic_interconvert(To& to, const From& from, const mpl::int_& /*to_type*/, const mpl::int_& /*from_type*/); + +} + + +namespace default_ops{ #ifdef BOOST_MSVC // warning C4127: conditional expression is constant @@ -894,6 +912,16 @@ inline void eval_convert_to(terminal* result, const B& backend) result->value = boost::lexical_cast(backend.str(0, std::ios_base::fmtflags(0))); } +template +inline void eval_convert_to(terminal >* result, const B2& backend) +{ + // + // We ran out of types to try for the conversion, try + // a generic conversion and hope for the best: + // + boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category(), number_category()); +} + template inline void eval_convert_to(std::string* result, const B& backend) { diff --git a/include/boost/multiprecision/detail/generic_interconvert.hpp b/include/boost/multiprecision/detail/generic_interconvert.hpp index aa6d3bf5..6a840f85 100644 --- a/include/boost/multiprecision/detail/generic_interconvert.hpp +++ b/include/boost/multiprecision/detail/generic_interconvert.hpp @@ -35,36 +35,37 @@ void generic_interconvert(To& to, const From& from, const mpl::int_::type limb_type; + typedef typename canonical::type l_limb_type; // get the corresponding type that we can assign to "To": - typedef typename canonical::type to_type; + typedef typename canonical::type to_type; From t(from); bool is_neg = eval_get_sign(t) < 0; if(is_neg) t.negate(); // Pick off the first limb: - limb_type limb; - limb_type mask = ~static_cast(0); + l_limb_type limb; + l_limb_type mask = static_cast(~static_cast(0)); From fl; eval_bitwise_and(fl, t, mask); eval_convert_to(&limb, fl); to = static_cast(limb); - eval_right_shift(t, std::numeric_limits::digits); + eval_right_shift(t, std::numeric_limits::digits); // // Then keep picking off more limbs until "t" is zero: // To l; - unsigned shift = std::numeric_limits::digits; + unsigned shift = std::numeric_limits::digits; while(!eval_is_zero(t)) { eval_bitwise_and(fl, t, mask); eval_convert_to(&limb, fl); l = static_cast(limb); - eval_right_shift(t, std::numeric_limits::digits); + eval_right_shift(t, std::numeric_limits::digits); eval_ldexp(l, l, shift); eval_add(to, l); - shift += std::numeric_limits::digits; + shift += std::numeric_limits::digits; } // // Finish off by setting the sign: diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 198eae6d..bee3b12d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -370,6 +370,7 @@ compile test_nothrow_mpfr.cpp : [ check-target-builds ../config//has_mpfr : : +#include +#include "test.hpp" + +#include +#include + +int main() +{ + using namespace boost::multiprecision; + + cpp_int i(20); + cpp_bin_float_50 f50(i); + BOOST_CHECK_EQUAL(f50, 20); + f50 = i.convert_to(); + BOOST_CHECK_EQUAL(f50, 20); + + int1024_t i1024(45); + cpp_bin_float_100 f100(i1024); + BOOST_CHECK_EQUAL(f100, 45); + f100 = i1024.convert_to(); + BOOST_CHECK_EQUAL(f100, 45); + + uint1024_t ui1024(55); + cpp_bin_float_100 f100b(ui1024); + BOOST_CHECK_EQUAL(f100b, 55); + f100b = ui1024.convert_to(); + BOOST_CHECK_EQUAL(f100b, 55); + + typedef number, et_off> i32_t; + i32_t i32(67); + cpp_bin_float_100 f100c(i32); + BOOST_CHECK_EQUAL(f100c, 67); + f100c = i32.convert_to(); + BOOST_CHECK_EQUAL(f100c, 67); + + typedef number, et_off> ui32_t; + ui32_t ui32(98); + cpp_bin_float_100 f100d(ui32); + BOOST_CHECK_EQUAL(f100d, 98); + f100d = ui32.convert_to(); + BOOST_CHECK_EQUAL(f100d, 98); + + return boost::report_errors(); +} + + + From 95a414c089c4f9b10225cc6b29566d0338300a06 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 20 Aug 2016 09:49:36 +0100 Subject: [PATCH 5/9] Fix spelling typo. --- include/boost/multiprecision/cpp_int.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/multiprecision/cpp_int.hpp b/include/boost/multiprecision/cpp_int.hpp index 3e830d2e..c348020d 100644 --- a/include/boost/multiprecision/cpp_int.hpp +++ b/include/boost/multiprecision/cpp_int.hpp @@ -1392,7 +1392,7 @@ private: } } // - // Exception guarentee: create the result in stack variable "result" + // Exception guarantee: create the result in stack variable "result" // then do a swap at the end. In the event of a throw, *this will // be left unchanged. // From 6e3f814cecf18adffe517a3e5820afa29dcc8f86 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 27 Aug 2016 18:27:54 +0100 Subject: [PATCH 6/9] Fix bug in self assignment of complex expression templates. Fixes https://svn.boost.org/trac/boost/ticket/12408. --- include/boost/multiprecision/number.hpp | 36 ++++++++++++------------- test/test_arithmetic.hpp | 22 +++++++++++++++ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index 62321a63..15af7ef8 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -761,7 +761,12 @@ private: bool bl = contains_self(e.left()); bool br = contains_self(e.right()); - if(bl && is_self(e.left())) + if(bl && br) + { + self_type temp(e); + temp.m_backend.swap(this->m_backend); + } + else if(bl && is_self(e.left())) { // Ignore the left node, it's *this, just add the right: do_add(e.right(), typename right_type::tag_type()); @@ -771,11 +776,6 @@ private: // Ignore the right node, it's *this, just add the left: do_add(e.left(), typename left_type::tag_type()); } - else if(bl && br) - { - self_type temp(e); - temp.m_backend.swap(this->m_backend); - } else if(!br && (bl || (left_depth >= right_depth))) { // br is always false, but if bl is true we must take the this branch: do_assign(e.left(), typename left_type::tag_type()); @@ -799,7 +799,12 @@ private: bool bl = contains_self(e.left()); bool br = contains_self(e.right()); - if(bl && is_self(e.left())) + if(bl && br) + { + self_type temp(e); + temp.m_backend.swap(this->m_backend); + } + else if(bl && is_self(e.left())) { // Ignore the left node, it's *this, just subtract the right: do_subtract(e.right(), typename right_type::tag_type()); @@ -810,11 +815,6 @@ private: do_subtract(e.left(), typename left_type::tag_type()); m_backend.negate(); } - else if(bl && br) - { - self_type temp(e); - temp.m_backend.swap(this->m_backend); - } else if(!br && (bl || (left_depth >= right_depth))) { // br is always false, but if bl is true we must take the this branch: do_assign(e.left(), typename left_type::tag_type()); @@ -839,7 +839,12 @@ private: bool bl = contains_self(e.left()); bool br = contains_self(e.right()); - if(bl && is_self(e.left())) + if(bl && br) + { + self_type temp(e); + temp.m_backend.swap(this->m_backend); + } + else if(bl && is_self(e.left())) { // Ignore the left node, it's *this, just add the right: do_multiplies(e.right(), typename right_type::tag_type()); @@ -849,11 +854,6 @@ private: // Ignore the right node, it's *this, just add the left: do_multiplies(e.left(), typename left_type::tag_type()); } - else if(bl && br) - { - self_type temp(e); - temp.m_backend.swap(this->m_backend); - } else if(!br && (bl || (left_depth >= right_depth))) { // br is always false, but if bl is true we must take the this branch: do_assign(e.left(), typename left_type::tag_type()); diff --git a/test/test_arithmetic.hpp b/test/test_arithmetic.hpp index 64bb46bd..955ef35a 100644 --- a/test/test_arithmetic.hpp +++ b/test/test_arithmetic.hpp @@ -2271,5 +2271,27 @@ void test() a = 20; a = a; BOOST_CHECK_EQUAL(a, 20); + + a = 2; + a = a * a * a; + BOOST_CHECK_EQUAL(a, 8); + a = 2; + a = a + a + a; + BOOST_CHECK_EQUAL(a, 6); + a = 2; + a = a - a + a; + BOOST_CHECK_EQUAL(a, 2); + a = 2; + a = a + a - a; + BOOST_CHECK_EQUAL(a, 2); + a = 2; + a = a * a - a; + BOOST_CHECK_EQUAL(a, 2); + a = 2; + a = a + a * a; + BOOST_CHECK_EQUAL(a, 6); + a = 2; + a = (a + a) * a; + BOOST_CHECK_EQUAL(a, 8); } From 1a7f9e5e3a6c1b0291cf092b3a104252885c8415 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 27 Aug 2016 18:44:25 +0100 Subject: [PATCH 7/9] History update. --- doc/html/boost_multiprecision/indexes/s01.html | 2 +- doc/html/boost_multiprecision/indexes/s02.html | 2 +- doc/html/boost_multiprecision/indexes/s03.html | 2 +- doc/html/boost_multiprecision/indexes/s04.html | 2 +- doc/html/boost_multiprecision/map/hist.html | 10 ++++++++++ doc/html/index.html | 2 +- doc/multiprecision.qbk | 2 ++ 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/html/boost_multiprecision/indexes/s01.html b/doc/html/boost_multiprecision/indexes/s01.html index c56f323f..5c13df9e 100644 --- a/doc/html/boost_multiprecision/indexes/s01.html +++ b/doc/html/boost_multiprecision/indexes/s01.html @@ -24,7 +24,7 @@

-Function Index

+Function Index

A B C D E F I L M N O P R S T V Z

diff --git a/doc/html/boost_multiprecision/indexes/s02.html b/doc/html/boost_multiprecision/indexes/s02.html index ce4c9220..9c6eb039 100644 --- a/doc/html/boost_multiprecision/indexes/s02.html +++ b/doc/html/boost_multiprecision/indexes/s02.html @@ -24,7 +24,7 @@

-Class Index

+Class Index

C D E F G I L M N T

diff --git a/doc/html/boost_multiprecision/indexes/s03.html b/doc/html/boost_multiprecision/indexes/s03.html index 17b4b33c..ec0b7a5d 100644 --- a/doc/html/boost_multiprecision/indexes/s03.html +++ b/doc/html/boost_multiprecision/indexes/s03.html @@ -24,7 +24,7 @@

-Typedef Index

+Typedef Index

C F I L M S T U

diff --git a/doc/html/boost_multiprecision/indexes/s04.html b/doc/html/boost_multiprecision/indexes/s04.html index 5610e302..c9ae6a59 100644 --- a/doc/html/boost_multiprecision/indexes/s04.html +++ b/doc/html/boost_multiprecision/indexes/s04.html @@ -23,7 +23,7 @@

-Index

+Index

A B C D E F G H I L M N O P R S T U V Z

diff --git a/doc/html/boost_multiprecision/map/hist.html b/doc/html/boost_multiprecision/map/hist.html index 4dc3f578..bd9412eb 100644 --- a/doc/html/boost_multiprecision/map/hist.html +++ b/doc/html/boost_multiprecision/map/hist.html @@ -100,6 +100,16 @@
  • Add modf support to complete C90 compatibility.
  • +
  • + Fix self assignment bug in expression template code for expressions such + as a = + a * + a * + a, see #12408. +
  • +
  • + Fixed some compiler errors that occur when converting from cpp_int to cpp_bin_float. +
  • diff --git a/doc/html/index.html b/doc/html/index.html index ddc140a4..29f5914e 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -166,7 +166,7 @@ - +

    Last revised: August 04, 2016 at 18:20:33 GMT

    Last revised: August 27, 2016 at 17:42:45 GMT


    diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk index 8e8ea456..7cb99d4b 100644 --- a/doc/multiprecision.qbk +++ b/doc/multiprecision.qbk @@ -5132,6 +5132,8 @@ should now respect signed-zeros correctly. * Fix fencepost error in rational to float conversion routines, see [@https://svn.boost.org/trac/boost/ticket/12327 #12327]. * Fix some Oracle C++ compiler compatibility issues. * Add modf support to complete C90 compatibility. +* Fix self assignment bug in expression template code for expressions such as `a = a * a * a`, see [@https://svn.boost.org/trac/boost/ticket/12408 #12408]. +* Fixed some compiler errors that occur when converting from `cpp_int` to `cpp_bin_float`. [h4 Multiprecision-2.2.7 (Boost-1.61)] From e33ada0fdcd70aec5acb5c90844a6b285c734461 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 27 Aug 2016 18:48:06 +0100 Subject: [PATCH 8/9] Fix typo in definition of checked_cpp_rational. Fixes https://svn.boost.org/trac/boost/ticket/11938. --- doc/html/boost_multiprecision/indexes/s01.html | 2 +- doc/html/boost_multiprecision/indexes/s02.html | 2 +- doc/html/boost_multiprecision/indexes/s03.html | 2 +- doc/html/boost_multiprecision/indexes/s04.html | 2 +- doc/html/boost_multiprecision/ref/cpp_int_ref.html | 2 +- doc/html/index.html | 2 +- doc/multiprecision.qbk | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/html/boost_multiprecision/indexes/s01.html b/doc/html/boost_multiprecision/indexes/s01.html index 5c13df9e..7d1704e5 100644 --- a/doc/html/boost_multiprecision/indexes/s01.html +++ b/doc/html/boost_multiprecision/indexes/s01.html @@ -24,7 +24,7 @@

    -Function Index

    +Function Index

    A B C D E F I L M N O P R S T V Z

    diff --git a/doc/html/boost_multiprecision/indexes/s02.html b/doc/html/boost_multiprecision/indexes/s02.html index 9c6eb039..b21591df 100644 --- a/doc/html/boost_multiprecision/indexes/s02.html +++ b/doc/html/boost_multiprecision/indexes/s02.html @@ -24,7 +24,7 @@

    -Class Index

    +Class Index

    C D E F G I L M N T

    diff --git a/doc/html/boost_multiprecision/indexes/s03.html b/doc/html/boost_multiprecision/indexes/s03.html index ec0b7a5d..0be585b1 100644 --- a/doc/html/boost_multiprecision/indexes/s03.html +++ b/doc/html/boost_multiprecision/indexes/s03.html @@ -24,7 +24,7 @@

    -Typedef Index

    +Typedef Index

    C F I L M S T U

    diff --git a/doc/html/boost_multiprecision/indexes/s04.html b/doc/html/boost_multiprecision/indexes/s04.html index c9ae6a59..6827ddbc 100644 --- a/doc/html/boost_multiprecision/indexes/s04.html +++ b/doc/html/boost_multiprecision/indexes/s04.html @@ -23,7 +23,7 @@

    -Index

    +Index

    A B C D E F G H I L M N O P R S T U V Z

    diff --git a/doc/html/boost_multiprecision/ref/cpp_int_ref.html b/doc/html/boost_multiprecision/ref/cpp_int_ref.html index f07b7efe..6a93e030 100644 --- a/doc/html/boost_multiprecision/ref/cpp_int_ref.html +++ b/doc/html/boost_multiprecision/ref/cpp_int_ref.html @@ -65,7 +65,7 @@ // Over again, but with checking enabled this time: typedef number<cpp_int_backend<0, 0, signed_magnitude, checked> > checked_cpp_int; typedef rational_adaptor<cpp_int_backend<0, 0, signed_magnitude, checked> > checked_cpp_rational_backend; -typedef number<cpp_rational_backend> checked_cpp_rational; +typedef number<checked_cpp_rational_backend> checked_cpp_rational; // Checked fixed precision unsigned types: typedef number<cpp_int_backend<128, 128, unsigned_magnitude, checked, void> > checked_uint128_t; diff --git a/doc/html/index.html b/doc/html/index.html index 29f5914e..e333e3fc 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -166,7 +166,7 @@
    - +

    Last revised: August 27, 2016 at 17:42:45 GMT

    Last revised: August 27, 2016 at 17:47:08 GMT


    diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk index 7cb99d4b..94183550 100644 --- a/doc/multiprecision.qbk +++ b/doc/multiprecision.qbk @@ -3709,7 +3709,7 @@ whose precision can vary at compile time (such as `mpf_float`). // Over again, but with checking enabled this time: typedef number > checked_cpp_int; typedef rational_adaptor > checked_cpp_rational_backend; - typedef number checked_cpp_rational; + typedef number checked_cpp_rational; // Checked fixed precision unsigned types: typedef number > checked_uint128_t; From b2108867c7415cc1ed28244843555289fdb8d356 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 15 Sep 2016 19:08:38 +0100 Subject: [PATCH 9/9] Fix for cpp_int conversions. --- include/boost/multiprecision/cpp_int/misc.hpp | 2 ++ test/test_cpp_bin_float_conv.cpp | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/boost/multiprecision/cpp_int/misc.hpp b/include/boost/multiprecision/cpp_int/misc.hpp index eb2f6f3a..0412ff14 100644 --- a/include/boost/multiprecision/cpp_int/misc.hpp +++ b/include/boost/multiprecision/cpp_int/misc.hpp @@ -541,6 +541,7 @@ template >::value && is_signed_number >::value + && boost::is_convertible::local_limb_type, R>::value >::type eval_convert_to(R* result, const cpp_int_backend& val) { @@ -574,6 +575,7 @@ template >::value && is_unsigned_number >::value + && boost::is_convertible::local_limb_type, R>::value >::type eval_convert_to(R* result, const cpp_int_backend& val) { diff --git a/test/test_cpp_bin_float_conv.cpp b/test/test_cpp_bin_float_conv.cpp index dffaba25..7c58eb82 100644 --- a/test/test_cpp_bin_float_conv.cpp +++ b/test/test_cpp_bin_float_conv.cpp @@ -51,6 +51,34 @@ int main() f100d = ui32.convert_to(); BOOST_CHECK_EQUAL(f100d, 98); + typedef number, et_off> i64_t; + i64_t i64(67); + cpp_bin_float_100 f100e(i64); + BOOST_CHECK_EQUAL(f100e, 67); + f100e = i64.convert_to(); + BOOST_CHECK_EQUAL(f100e, 67); + + typedef number, et_off> ui64_t; + ui64_t ui64(98); + cpp_bin_float_100 f100f(ui64); + BOOST_CHECK_EQUAL(f100f, 98); + f100f = ui64.convert_to(); + BOOST_CHECK_EQUAL(f100f, 98); + + typedef number, et_off> i128_t; + i128_t i128(67); + cpp_bin_float_100 f100g(i128); + BOOST_CHECK_EQUAL(f100g, 67); + f100g = i128.convert_to(); + BOOST_CHECK_EQUAL(f100g, 67); + + typedef number, et_off> ui128_t; + ui128_t ui128(98); + cpp_bin_float_100 f100h(ui128); + BOOST_CHECK_EQUAL(f100h, 98); + f100h = ui128.convert_to(); + BOOST_CHECK_EQUAL(f100h, 98); + return boost::report_errors(); }