C++ 中的四倍精度(海湾合作委员会)
就在最近,GCC 4.6.0 与 libquadmath 一起发布。不幸的是,GNU 支持 Fortran,但不支持 C 或 C++(所包含的只是 .so)。我还没有找到在 C++ 中使用这些新功能的方法,但是,GNU C 确实支持 __float128 类型以保证四倍精度浮点数。 GNU C 似乎不支持 libquadmath 中的数学函数,例如 fabsq (绝对值,
q
是四边形的后缀)。
有没有办法让这些函数在 C++ 中工作,或者是否有一些替代库可以用于带有 __float128
的数学函数?在 GCC 中获得四精度浮点数的最佳方法是什么?现在,我可以对它们进行加、减和乘,但这对我来说毫无用处,因为我无法将它们转换为字符串或使用诸如 truncq
和 fabsq< 之类的函数/code> 创建我自己的字符串函数。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,这似乎是我的安装错误。
虽然 GCC 的核心 C/C++ 部分包含 libquadmath.so,但 Fortran 版本提供 libquadmath.a 和quadmath.h,可以包含它们来访问函数。
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.
nm .so 文件,看看函数名称到底是什么。 IIRC,Fortran 例程的名称末尾有一个 _。在 C++ 中,您需要 extern "C" {} 原型。如果这是一个 Fortran 接口,那么所有参数都通过引用传递,所以 proto 可能类似于
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