float 和 double 的精度
来源:互联网 发布:iphone 网络电视 编辑:程序博客网 时间:2024/06/06 05:22
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;
}
{
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;
}
阅读全文
0 0
- float 和 double 的精度
- float和double的范围和精度
- float和double的范围和精度
- float和double的范围和精度
- float和double的范围和精度
- float 和 double的精度和范围
- float和double的范围和精度
- double 和float的范围和精度
- 关于float和double的精度问题
- float与double的范围和精度
- float与double的范围和精度
- float与double的范围和精度
- float与double的范围和精度
- float与double的范围和精度
- float与double的范围和精度
- 注意,float和double的精度
- float和double的精度问题
- float与double的范围和精度
- git场景命令使用
- 牛客网-剑指offer-从头到尾打印链表
- C++ _access和_waccess的使用方法
- js中逻辑运算符|| 的返回值并不只有true和false
- 反转链表
- float 和 double 的精度
- Oracle表分区详解(优缺点)
- js 格式化 extjs 的时间对象 Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)
- 刷题——Coins POJ
- ifstream&&ofstream的.csv文件读写
- Matrix 网络流
- HDU 2852 KiKi's K-Number *(树状数组)
- org.json:json包
- 解决导入maven项目时下载出错不完整报Failure to transfer 等问题