Quadruple Precision in C++ (GCC)

前端 未结 2 1449
名媛妹妹
名媛妹妹 2020-12-05 15:33

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

相关标签:
2条回答
  • 2020-12-05 16:11

    nm the .so file, and see what function names really are. IIRC, fortran routines have an _ at end of name. In C++, you'll need to extern "C" {} prototypes. If this is a fortran interface, then all args are passed by reference, so proto might be something like

    extern "C" { long double fabsq_(long double* x); }
    
    0 讨论(0)
  • 2020-12-05 16:20

    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;
    }
    
    0 讨论(0)
提交回复
热议问题