小编use*_*863的帖子

Visual C++ 将流读取为双精度时的奇怪行为

我在 Visual Studio 2022(版本 17.7.1)中遇到一个奇怪的问题。在下面的程序中:

#include <iostream>
#include <sstream>
using namespace std;

int main()
{
    istringstream istr("1e-07 3");
    double xx = 0;
    int yy = 0;
    istr >> xx >> yy;
    cout << "xx = " << xx << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

该程序将根据运行时库和平台工具集进行不同的打印:

Toolset v143, Multi-threaded Debug or Multi-threaded: 1e-06
Toolset V143, Multi-threaded Debug DLL or Multi-threaded DLL: 1e-07
Toolset v142, Multi-threaded Debug or Multi-threaded: 1e-07
Toolset V142, Multi-threaded Debug DLL or Multi-threaded DLL: 1e-07
Run Code Online (Sandbox Code Playgroud)

有人可以证实这一点吗?如果这是编译器中的一个实际错误,我会感到惊讶。

谢谢。

c++ double runtime stream

9
推荐指数
1
解决办法
251
查看次数

标签 统计

c++ ×1

double ×1

runtime ×1

stream ×1