From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Alessandro Tagliapietra
Sent: Monday, April 22, 2013 5:19 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] Cpp_int and cpp_dec_float conversion

 

Hello,

 

is there a way to convert from cpp_int to cpp_dec_float and viceversa?

 

Since I've to use the modulus between two cpp_dec_float which I know they're integers but I need sqrt before and trying to run % with them gives:

 

/usr/local/include/boost/multiprecision/number.hpp: In member function ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::do_assign(const Exp&, const boost::multiprecision::detail::modulus_immediates&) [with Exp = boost::multiprecision::detail::expression<boost::multiprecision::detail::modulus_immediates, boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, void, void>, Backend = boost::multiprecision::backends::cpp_dec_float<100u, int, void>, boost::multiprecision::expression_template_option ExpressionTemplates = et_on]’:
/usr/local/include/boost/multiprecision/number.hpp:680:   instantiated from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::do_assign(const boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>&, const mpl_::true_&) [with tag = boost::multiprecision::detail::modulus_immediates, Arg1 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg2 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg3 = void, Arg4 = void, Backend = boost::multiprecision::backends::cpp_dec_float<100u, int, void>, boost::multiprecision::expression_template_option ExpressionTemplates = et_on]’
/usr/local/include/boost/multiprecision/number.hpp:134:   instantiated from ‘typename boost::enable_if<boost::is_convertible<typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, boost::multiprecision::number<Backend, ExpressionTemplates> >, boost::multiprecision::number<Backend, ExpressionTemplates>&>::type boost::multiprecision::number<Backend, ExpressionTemplates>::operator=(const boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>&) [with tag = boost::multiprecision::detail::modulus_immediates, Arg1 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg2 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg3 = void, Arg4 = void, Backend = boost::multiprecision::backends::cpp_dec_float<100u, int, void>, boost::multiprecision::expression_template_option ExpressionTemplates = et_on]’
/usr/local/include/boost/multiprecision/number.hpp:181:   instantiated from ‘boost::multiprecision::number<Backend, ExpressionTemplates>::number(const boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>&, typename boost::enable_if_c<boost::is_convertible<typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type,boost::multiprecision::number<Backend, ExpressionTemplates> >::value, void>::type*) [with tag = boost::multiprecision::detail::modulus_immediates, Arg1 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg2 = boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<100u, int, void>, et_on>, Arg3 = void, Arg4 = void, Backend = boost::multiprecision::backends::cpp_dec_float<100u, int, void>, boost::multiprecision::expression_template_option ExpressionTemplates = et_on]’
test.cpp:20:   instantiated from here
/usr/local/include/boost/multiprecision/number.hpp:912: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’

 

 

 

I'm sure John Maddock will give a fully informed reply to this, but this

 

boost::multiprecision::expression_template_option ExpressionTemplates = et_on

 

suggests that you might try setting the 'use  expression templates' template parameter to NOT use ET

 

boost::multiprecision::expression_template_option ExpressionTemplates = et_off

 

HTH

 

Paul

 

 

---

Paul A. Bristow,

Prizet Farmhouse, Kendal LA8 8AB  UK

+44 1539 561830  07714330204

pbristow@hetp.u-net.com