如何在VC ++中将指数值转换为两倍? [英] How to convert exponentioal values to double in VC++?
本文介绍了如何在VC ++中将指数值转换为两倍?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
"3.1e-05"这是字符串,我想将此字符串转换为数字输出,结果为1.00003
"3.1e-05" this is the string and I want to convert this string into numeric output ll be 1.00003
Any suggestion will be greatly appreciated.
推荐答案
使用sscanf有什么问题?
干杯!
What''s wrong with using sscanf?
Cheers!
是字符串还是char*
?假设是后者,
Is it a string orchar*
? Assuming the latter,
#include <stdlib.h>
const char* str = "3.1e-05";
//...
double value = atof(str);
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR* e;
_tprintf(__T("%.5lf"),_tcstod(1<argc?argv[1]:__T("3.1e-05"),&e));
_gettch();
return 0;
}
很简单,不是吗?
Thats easy, isnt?
这篇关于如何在VC ++中将指数值转换为两倍?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文