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字符串(双值)
{
字符串结果;
串流转换;
转换Addconvertstd::fixed