linux - 设置 ostream linux/visual studio 的指数字段的宽度

标签 linux visual-studio-2010 gcc exponent

我需要运行一个在 Linux 和 Visual Studio 上都有类似输出的程序。

Linux 的指数字段默认宽度为 2,而 Visual Studio 的默认宽度为 3。

因此,对于数字 3.40282e+38,Linux 保持原样,但 Visual Studio 会用额外的 0、3.40282e+038 填充它

有人知道如何在 Visual Studio 中配置输出以删除零吗? (或者在 Linux 中添加零)

最佳答案

根据维基百科:http://en.wikipedia.org/wiki/Printf_format_string

The exponent always contains at least two digits; if the value is zero, the exponent is 00. In Windows, the exponent contains three digits by default, e.g. 1.5e002, but this can be altered by Microsoft-specific _set_output_format function.

所以看起来你可以要求微软的编译器不要添加零。不过,我不知道如何要求 gcc 添加零。

关于linux - 设置 ostream linux/visual studio 的指数字段的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9653489/

相关文章:

linux - linux 中的 wxString Printf 函数问题

php - HHVM 与 FastCGI 安装错误

c - 简单数组初始化填充在 Linux (CentOS) 中有效,但在 Windows 中无效

html - Windows 资源管理器中未显示解决方案文件夹

.net - 在 wpf 中,如何使用标准对话框来选择目录

.net - TFS 覆盖所有相同的文件

python - 在 CentOS 与 python 2.6 上针对 information_schema 执行 "SELECT"语句时,psycopg2 挂起

c++ - 我可以升级 Xcode 以支持更新版本的 GCC 来学习 C++0x 吗?

c++ - strcpy_s 不适用于 gcc

gcc - CMake 相对包含 C++ 中的路径