float 和 double 的精度

int main()
{
using namespace std;
float a = 2.34E+22f;
float b = a + 1.0f;


cout << "a = " << a << endl;
cout << "b - a = " << b - a << endl;


cin.get();
cin.get();
return 0;
}


int main()
{
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield); //fixed point


float tub = 10.0f / 3.0f;
double mint = 10.0 / 3.0;
const float million = 1.0e6;


cout << "tub = " << tub;
cout << ", a million tubs = " << million * tub;
cout << ", \nand ten million tubs = " << 10 * million * tub <<endl;


cout << "mint = " << mint << " and a million mints = " << million * mint << endl;


cin.get();
cin.get();
return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_39885625/article/details/77365919