warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
来源:互联网 发布:剑桥 知乎 编辑:程序博客网 时间:2024/06/07 02:50
在32位平台上,通常int是4字节长度,最多表示到21亿多,而int型是“绝对精确”的,换句话说,就是int行最多可以保证10位十进制有效数字的精确度。
而float只能保证6位有效数字的精确度,因此int到float的转换是可能丢失精度的,比如整数“1234567899”转换成float后,大约是:1.23457936乘10的9次方,也就是从第7位有效数字开始已经不准确了。
double可以保证15位10进制有效数字的精度,所以从int到double不会有这个警告。
在32位平台上,通常int和float都是4字节的,那既然字节数一样,凭什么int只能表示到21亿,而float可以表示到10的38次方?答案就是float跟int相比,牺牲了精确度,换来了更大的表示范围。
0 0
- warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
- warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- vs2005 warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
- How to eliminate the compile error "conversion from 'double ' to 'float ', possible loss of data"
- 使用CodeWarrior编译时出现Warning:Possible loss of data
- Some search result of float to int conversion
- Conversion to double from cell is not possible.
- warning C4244
- warning C4047: '=' : 'int *' differs in levels of indirection from 'int (*)[3]'
- warning: deprecated conversion from string constant to ‘char的解决方法
- warning: deprecated conversion from string constant to ‘char*’
- warning: deprecated conversion from string constant to "char *"
- warning:deprecated conversion from string constant to 'char *'
- warning: deprecated conversion from string constant to 'char*'
- warning:deprecated conversion from string constant to 'char *'解决方案
- python中如何调用shell
- JAVA test_MouseAdapter
- JAVA中String的深入研究
- CentOS 6.2+Nginx+Nagios,手机短信和qq邮箱提醒
- Poj 1050
- warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
- 高效开发Android App的10个建议
- [笨笨的方法] 实现IOS列表的滑动删除效果
- ecshop去掉头部和页尾版权,以及乱跑的Powered by ECShop v2.7.2
- 数据类型和字符编码的关系
- 生命的起源
- OpenCV FileStorage类读写XML/YML文件
- Android UI:看看Google官方自定义带旋转动画的ImageView-----RotateImageView怎么写(附 图片淡入淡出效果)
- HTTP条件Get(Conditional Get)