![]() |
Home | Libraries | People | FAQ | More |
Since few compilers implement a true 128-bit floating-point, and language features
like the suffix Q (which may need an option -fext-numeric-literals
to enable), and C++ Standard library functions are as-yet missing or incomplete
in C++11, this Boost.Math implementation wraps __float128
provided by the GCC compiler GCC
floating-point types or the _Quad
type provided by the Intel compiler.
This is provided to in order to demonstrate, and users to evaluate, the feasibility and benefits of higher-precision floating-point, especially to allow use of the full <cmath> and Boost.Math library of functions and distributions at high precision.
(It is also possible to use Boost.Math with Boost.Multiprecision decimal and binary, but since these are entirely software solutions, allowing much higher precision or arbitrary precision, they are likely to be slower).
We also provide (we believe full) support for <limits>, <cmath>
, I/O stream operations in <iostream>
, and <complex>
.
As a prototype for a future C++ standard, we place all these in namespace std
.
This contravenes the existing C++ standard of course, so selecting any compiler
that promises to check conformance will fail.
![]() |
Tip |
---|---|
For GCC, compile with |
The __float128
type is provided
by the libquadmath
library on GCC or by Intel's FORTRAN library with Intel C++. They also
provide a full set of <cmath>
functions in namespace
std
.
The source code is at quadmath_snprintf.c.
float128
quadmath type
For C++ programs, you will want to use the C++ type float128
See example at cstdfloat_example.cpp.
A typical invocation of the compiler is
g++ -O3 -std=gnu++11 test.cpp -I/c/modular-boost -lquadmath -o test.exe
![]() |
Tip |
---|---|
If you are trying to use the develop branch of Boost.Math, then make |
g++ -O3 -std=gnu++11 test.cpp -I/c/modular-boost/libs/math/include -I/c/modular-boost -lquadmath -o test.exe
![]() |
Note |
---|---|
So far, the only missing detail that we had noted was in trying to use Link fails: undefined reference to typeinfo for __float128. See GCC Bug 43622 - no C++ typeinfo for __float128. But this is reported (Marc Glisse 2015-04-04 ) fixed in GCC 5 (and above). For example, with GCC6.1.1 this works as expected to a mangled string name, and output (if possible - not always). const std::type_info& tifu128 = typeid(__float128); // OK. //std::cout << tifu128.name() << std::endl; // On GCC, aborts (because not printable string). //std::cout << typeid(__float128).name() << std::endl; // Aborts - string name cannot be output. const std::type_info& tif128 = typeid(float128); // OK. std::cout << tif128.name() << std::endl; // OK. std::cout << typeid(float128).name() << std::endl; // OK. const std::type_info& tpi = typeid(pi1); // OK GCC 6.1.1 (from GCC 5 according to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43622) std::cout << tpi.name() << std::endl; // Output mangled name: // N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE |