在窗口上的float中额外的0打印
Extra 0 print in float on windows
我有一个程序显示不同的打印(在windows上额外的0),我试图使它与linux相同。在windows上使用Visual studio 2012。linux下使用g++ v4.8.3
有什么建议吗
我创建了一个小程序来展示我所面临的问题…
#include "stdafx.h"
#include <stdio.h>
int main()
{
float f = -1e-14;
printf("nn t Lets print the float value -1e-14 as [%9.3g] nnnn",f);
return 0;
}
linux:
/home/mag>./a.out
Lets print the float value -1e-14 as [ -1e-14]
在windows上:(注意-1e-014中额外的0)
Lets print the float value -1e-14 as [ -1e-014]
我试图使其相同的原因是因为我正在调试windows和linux的一些输出,而windows和linux的输出之间的巨大差异是由于上述问题造成的,因此我错过了重要的差异。
首先调用_set_output_format(_TWO_DIGIT_EXPONENT)
,使printf()
在VS2012中使用两位数指数
相关文章:
- 如何循环打印顶点结构
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 如何在c++中打印目录
- 有一个打印语句的函数是一种糟糕的编程实践吗
- 在线编译器中的分段C++没有打印消息
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 如何将结构插入到集合中并打印集合的成员
- 在循环C++中指定字符串之后,不会打印该字符串
- 以螺旋方式打印矩阵的程序.(工作不好)
- 从控制台中删除最后打印的元素
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何仅使用对象名称打印特定于对象的成员
- 回溯C++不打印函数,因此文件
- 在一定长度后从数组中打印时缺少整数
- 为什么这个 c++ 代码打印出长度 5,当我打印出字符串时,程序会自动终止?
- 在gem5中打印文件中的所有cache_blocks
- Caffe在net_.reset上打印整个protext文件(new Net<float>(model_file,TEST))
- <float>用"%x"打印numeric_limits::infinity()时会发生什么?
- 在窗口上的float中额外的0打印