浮点精度
来源:互联网 发布:wpf高级编程 pdf 网盘 编辑:程序博客网 时间:2024/04/28 07:44
#include <iostream>#include<cstdio>using namespace std;int main(){ int a=0; double k=1; while(k>0){ k=k/10; a++; } printf("%d\n",a); return 0;}
输出a=324,但这并不是精度
#include <iostream>#include<cstdio>using namespace std;int main(){ int a=0; float k=1; while(k>0){ k=k/10; a++; } printf("%d\n",a); return 0;}
输出46,也不是精度
类型 符号位 阶码 尾数 长度 2的尾数次方 精确位数 指数范围
float 1 8 23 32 8388608 6 -128~127
double 1 11 52 64 4503599627370496 15 -1024~1023
临时数 1 15 64 80 18446744073709551616 19 -32768~32767
#include <iostream>#include<cstdio>using namespace std;int main(){ freopen("out","w",stdout); int a=0; double k=1; while(k>0){ k=k/10; a++; printf("%d\n%.324lf\n",a,k); } return 0;}从下面的运行结果看,精度为15
#include <iostream>#include<cstdio>using namespace std;int main(){ freopen("out","w",stdout); int a=0; float k=1; while(k>0){ k=k/10; a++; printf("%d\n%.324lf\n",a,k); } return 0;}考虑到计算的浮点误差,在合理的范围内,9的个数稳定在6
参考:http://blog.csdn.net/lai123wei/article/details/7220684
0 0
- 浮点精度
- PHP浮点精度问题
- 浮点数精度
- 浮点精度转换
- 浮点数精度
- 浮点数精度错误
- 浮点精度转换
- 浮点数精度问题
- java浮点精度总结
- JAVA 浮点精度问题
- 单精度浮点数
- 浮点数精度
- 浮点精度问题
- 浮点数精度
- 浮点数精度整理
- 浮点数精度控制
- Java浮点运算精度
- 浮点数精度问题
- http://photo.renren.com/photo/827157467/album-1034046772
- 2015年大数据市场规模超过170亿美元
- 变形金刚4:绝迹重生中文字幕抢先版BT种子下载
- 简单外中断实验(最近又要搞arm相关的东西,复习一下中断)
- poj 2513 欧拉回路+并查集判断是否联通+Trie树
- 浮点精度
- 里氏替换原则
- JdbcTemplate及报错'dataSource' or 'jdbcTemplate' is required
- 测试一下机器
- Windows下Hello Word程序
- Ibibo Interview Question Software Engineer / Developers
- STL: string
- LeetCode 65. Add Binary
- 2014年7月7日-7月13日计划及执行情况(共36小时,剩4376小时