Just recently, the GCC 4.6.0 came out along with libquadmath. Unfortunately, GNU has supported Fortran, but not C or C++ (all that is included is a .so). I have not found a way to use these new features in C++, however, GNU C does support the __float128
type for guaranteed quadruple-precision floats. GNU C does not seem to support the math functions in libquadmath, such fabsq
(absolute value, q
being the suffix for quad).
Is there any way to get these functions working in C++, or is there some alternative library that I could use for math functions with __float128
? What is the best method for getting quadruple-precision floats working in the GCC? Right now, I can add, subtract, and multiply them, but this is useless to me, considering how I have no way to convert them to strings or use functions such as truncq
and fabsq
to create my own string function.
GCC versions 4.0 and higher support 128-bit quad precision floating point values. The XL compilers now provide the -qfloat=gcclongdouble option to be compatible with GCC's representation of 128-bit quad precision floating point values.
libquadmath, the GCC Quad-Precision Math Library Application Programming Interface (API)
Apparently, this seems to have been an installation error on my part.
While the core C/C++ portion of the GCC includes libquadmath.so, the Fortran version supplies libquadmath.a and quadmath.h, which can be included to access the functions.
#include <quadmath.h>
#include <iostream>
int main()
{
char* y = new char[1000];
quadmath_snprintf(y, 1000, "%Qf", 1.0q);
std::cout << y << std::endl;
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With