miy*_*iya 14 c++ math scientific-notation type-conversion
我有一个数据库填充了以下双打:
1.60000000000000000000000000000000000e+01
Run Code Online (Sandbox Code Playgroud)
有人知道如何在C++中将这样的数字转换为double吗?
是否有"标准"方式来做这类事情?或者我必须自己动手?
现在我正在做这样的事情:
#include <string>
#include <sstream>
int main() {
std::string s("1.60000000000000000000000000000000000e+01");
std::istringstream iss(s);
double d;
iss >> d;
d += 10.303030;
std::cout << d << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
Tho*_*mas 18
像这样的东西?这将是"C++"的做法......
#include <sstream>
using namespace std;
// ...
string s = "1.60000000000000000000000000000000000e+01";
istringstream os(s);
double d;
os >> d;
cout << d << endl;
Run Code Online (Sandbox Code Playgroud)
打印16.
| 归档时间: |
|
| 查看次数: |
21103 次 |
| 最近记录: |