简体   繁体   中英

C++: convert “boost::multiprecision::float128” to “double”

I'm using the boost multiprecision library, and more precisely the boost::multiprecision::float128 type. Using ICPC for compiling, I get some errors when trying to to do something like:

double a = functionA();

where functionA() return a boost::multiprecision::float128 variable.

error: no suitable conversion function from "boost::multiprecision::float128" to "double" exists|

How can I solve this?

From the Boost documentation:

A number can be converted to any built in type, via the convert_to member function:

mpz_int z(2);
double i = z.convert_to<double>(); // sets i to 2

http://www.boost.org/doc/libs/1_57_0/libs/multiprecision/doc/html/boost_multiprecision/tut/conversions.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM