在C++中是否有任何命令可以制作,
1.354322e-23
Run Code Online (Sandbox Code Playgroud)
成
0
Run Code Online (Sandbox Code Playgroud)
这是我的(简单)程序
#include "stdafx.h"
#include <iostream>
#include<iomanip>
int main()
{
float x;
std::cin >> x;
std::cout << x << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我输入值时,
2.2356e-17
Run Code Online (Sandbox Code Playgroud)
它给,
2.2356e-017
Run Code Online (Sandbox Code Playgroud)
std::setprecision 不会工作......
编辑: 好的,这是我的问题.我创建了一个程序,可以给出sin cos和tan值.
对于cos 90,我希望它为0而不是-4.311e-008
继承人我的真实计划
#include "stdafx.h"
#include <iostream>
#include<iomanip>
float Pi()
{
float pi = (atan(1) * 4);
return pi;
}
int Selector()
{
using namespace std;
cout << "Type:\t1 for Degrees\n\t2 for Radians\n\t3 for Gradians\n\nYour Choice : ";
int x; …Run Code Online (Sandbox Code Playgroud)