I try to use float128 from boost library. I connect this way:

#include <boost/multiprecision/float128.hpp> namespace mp = boost::multiprecision; mp::float128 N = 0; 

Gives the error: #error: "Sorry compiler is not GCC, not Intel, What is the error? Or tell me what type of data from this library can be used to work with a large number of floating point.

Update

How to interact now the whole type of boost c float? It turns out so: I connect library:

 #include <boost/multiprecision/cpp_bin_float.hpp> namespace mp = boost::multiprecision; mp::cpp_bin_float_quad N = 1010.5; mp::cpp_int a=5; 

Now when I try to divide this number into a whole large number from this library:

 N/=5; 

produces an error: there is no operator "/ =" corresponding to these operands. How can you use these two types at the same time?

    1 answer 1

    As the Boost documentation says :

    GCC's float128 number is a very thin wrapper around it, and it is a bit of a wrinkle wrapper around it. FORTRAN's 128-bit QUAD real.

    Those. it's just a wrapper on type float128 from gcc. Use it with other compilers will not work. What is said in the error.

    The implementation of binary floating-point arithmetic with arbitrary precision from boost is called cpp_bin_float . In fact, this is the only FP-backend outside the GNU world. Relatively slow, but without dependencies.

    The analogue directly float128 is the type cpp_bin_float_quad .

     #include <boost/multiprecision/cpp_bin_float.hpp> using namespace boost::multiprecision; cpp_bin_float_quad N = 0; 

    Update

    In order to use different types from arbitrary precision boost libraries in one expression, they must be explicitly converted to one of the convert_to<>() methods , for example, using the convert_to<>() template:

     #include <iostream> #include <boost/multiprecision/cpp_bin_float.hpp> #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; int main(void) { cpp_bin_float_quad fpN = 1; cpp_int iN = 5; cpp_bin_float_quad fp2; fpN /= iN.convert_to<cpp_bin_float_quad>(); std::cout << fpN; return 0; } 
    • There are new problems, please see the updated topic. - Alexander
    • @Alexander, it’s not worth changing the part of the question that has already been answered ... It is either asking a new question with cross-references to the current one, or adding a clarification below the main question clearly denoting it as such (for example, the subheading **Update** ). - Fat-Zer
    • Thanks, corrected the remark. - Alexander