Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何防止由“生成的字符串使用科学记数法”;“数字到字符串”;功能?_C++_String - Fatal编程技术网

C++ 如何防止由“生成的字符串使用科学记数法”;“数字到字符串”;功能?

C++ 如何防止由“生成的字符串使用科学记数法”;“数字到字符串”;功能?,c++,string,C++,String,我有一个数字到字符串的函数,它将数字转换成字符串。现在我想输出不带科学符号的结果字符串。这是我的密码: #include <iostream> #include <sstream> using namespace std; string number_to_string( double value ) { string result; stringstream convert; convert << value; resul

我有一个数字到字符串的函数,它将数字转换成字符串。现在我想输出不带科学符号的结果字符串。这是我的密码:

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

string number_to_string( double value )
{
    string result;
    stringstream convert;

    convert << value;
    result = convert.str();

    return result;
}

int main()
{
    double d = 591284081248903124;
    string s = number_to_string( d );
    cout << s << endl; // why it shows 5.91284e+17 ?!?!

    return 0;
}
#包括
#包括
使用名称空间std;
字符串编号\u到\u字符串(双值)
{
字符串结果;
串流转换;
转换Add
convert
std::fixed