首页 > 其他 > 详细

double数据的存储细节

时间:2015-10-28 15:54:37      阅读:264      评论:0      收藏:0      [点我收藏+]

浮点数在计算机内的存储是怎样的呢?以双精度浮点数为例来说吧:

Most nonzero ?oating-point numbers are normalized. This means they can be   expressed as :         x = ±(1 + f) *2^e

Double-precision ?oating-point numbers are stored in a 64-bit word, with 52bits for f, 11 bits for e, and 1 bit for the sign of the number. The number 1 was not actually stored for its default property . In e?ect, the IEEE format packs 65 bits of information into a 64-bit word.

这就是双精度浮点(double)型数据,占8 个字节(64位)内存空间。但是其数值范围为1.7E-308~1.7E+308,双精度完全保证的有效数字是15位,也就是那对应f的52位的二进制数所能表示的f的十进制数的范围。

eps is the distance from 1 to the next larger ?oating-point number. For IEEE double-precision, eps = 2^(-52).即是f的最小值。The approximate decimal value of eps is 2.2204·10 ?16.

In either case, you can say that the roundo? level is about 16 decimal digits.16位只是部分数值的精确度有保证。

关于小数0.1的存储细节,可以参考这篇博客

double数据的存储细节

原文:http://my.oschina.net/donngchao/blog/523083

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!