使用cout进行双重表示
double representation using cout
我有一个简单的程序:
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
double i=0.000006;
printf("%lfn",i);
cout <<i<<endl;
return 0;
}
,其输出为:
pearl.236> ./a.out
0.000006
6e-06
pearl.237>
如何使用cout
实现0.000006 ?
我遇到的实际问题是我将这个双精度重定向到字符串流,然后我将它打印在屏幕上。我想知道如何在字符串流中存储实际的双精度表示
在操纵符的帮助下实现流格式化。指定标准符号和科学符号的操纵符为fixed
和scientific
。
cout << fixed <<i<<endl;
尝试使用std::fixed
std::cout << std::fixed << i << "n";
相关文章:
- 表示"accepting anything for this template argument" C++概念的通配符
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 如何将ampl中的集合表示为c++中的向量
- std::cout.imbue()多重调用
- std::is_base_of表示ctor编译错误
- 输入中的字符串数未知(以字母表示)
- 我可以信任表示整数的浮点或双精度来保持精度吗
- 如何在C++中用std::cout正确显示带十六进制的字符串文本
- 为什么在C的循环中使用printf的Rust代码不显示输出,而在C++的循环中显示std::cout
- c++模板来表示多项式
- 为什么我应该在异常处理中使用std::cerr而不是std::cout
- 询问在设计我的手臂模拟器功能表示格式1
- CMakeLists.txt中的命名空间表示法
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 如何计算Big-O表示法中的平均渐近运行时间
- 我应该如何表示我拥有的连续元素序列?
- 在作为静态成员包含在另一个类中的类的构造函数中使用 cout
- 在C++中,使用带有 std::optional 参数的函数<T>来表示可选参数是否有意义?
- 使用cout进行双重表示
- C++ cout 和枚举表示形式