G++ 4.6.3 Linux 中使用 quadmath 的四倍精度
Quadruple precision in G++ 4.6.3 Linux using quadmath
我尝试执行代码
#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;
}
使用此命令
g++ test.cpp -o test
但是我得到了错误:
/tmp/cctqto7E.o: In function `main':
test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*, unsigned int, char const*, ...)'
collect2: ld returned 1 exit status
版本为:
g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
如何解决问题?
我看到了相同的行为:
~/coding/q$ g++ test.cpp -lquadmath
/tmp/ccYdHwL5.o: In function `main':
test.cpp:(.text+0x51): undefined reference to `quadmath_snprintf(char*, unsigned int, char const*, ...)'
collect2: ld returned 1 exit status
一种解决方法是改用此模式包含标头:
extern "C" {
#include "quadmath.h"
}
之后:
~/coding/q$ g++ test.cpp -lquadmath
~/coding/q$ ./a.out
1.000000
相关文章:
- 将非常大的 int 转换为双倍,在某些计算机上会损失精度
- 双倍精度太高
- Qt 是 JSON 精度的两倍
- 如何将固定精度的两倍格式化为给定的长度
- 在 Python 中以与 C++ 相同的精度乘以双倍
- Linux与Mac上的四倍精度
- 在C 中声明一个八倍精度浮点变量
- 使用 cout 以精度 4 打印双倍
- 如何在 C/C++ 中有效地计算双倍到两个小数点精度
- G++ 4.6.3 Linux 中使用 quadmath 的四倍精度
- 如何以最大精度存储双倍
- C++中是否有一个浮点文字后缀来使数字的精度翻倍
- 双倍到科学记数法转换 - 精度误差
- 如何通过谷歌glog打印完全双倍精度
- IEEE-754浮点、双精度和四精度是否保证-2、-1、-0、0、1、2的精确表示
- C++ 精度使用长长与双倍
- 将双精度转换为 10 的整数倍
- 乘以10的倍数时丢失双倍精度
- c++ pthread多线程2倍Intel Xeon X5570,四核cpu在亚马逊EC2 HPC ubuntu实例
- 为什么优化标志 (-O3) 不能加快四倍精度计算的速度?