将科学计数法中的数字转换为十进制
convert numbers in scientific notation to decimal
编写一个 C 程序,将科学记数法中的数字转换为其等效的十进制形式:
鉴于
8.3e+2 输出 = 830
2.E-1 输出 = 0.2
4.3E2输出=430
C/C++ 中是否有任何内置库或函数可以做到这一点?
或者必须自己编写代码,在这种情况下,有什么简单的方法可以实现吗?
试试这个
#include <iostream>
#include <string>
int32_t main(int32_t argc, char *argv[]) {
std::string str = "8.3e+2";
std::cout << std::stod(str) << std::endl;
return EXIT_SUCCESS;
}
编写一个 C 程序,将科学记数法中的数字转换为其等效的十进制形式:
鉴于
8.3e+2 输出 = 830
2.E-1 输出 = 0.2
4.3E2输出=430
C/C++ 中是否有任何内置库或函数可以做到这一点?
或者必须自己编写代码,在这种情况下,有什么简单的方法可以实现吗?
试试这个
#include <iostream>
#include <string>
int32_t main(int32_t argc, char *argv[]) {
std::string str = "8.3e+2";
std::cout << std::stod(str) << std::endl;
return EXIT_SUCCESS;
}