用C彩车$ P​​ $ pcision [英] Precision in C floats

查看:114
本文介绍了用C彩车$ P​​ $ pcision的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般我们说,一个有浮动小数点后6位precision。但是,如果我们存储大量的10 ^ 30的顺序的,我们将不小数点后得到6位数字。因此,它是正确的说,花车有6位数的precision小数点后?

Generally we say that a float has precision of 6 digits after the decimal point. But if we store a large number of the order of 10^30 we won't get 6 digits after the decimal point. So is it correct to say that floats have a precision of 6 digits after the decimal point?

推荐答案

小数点后6位是nonesnse,你的例子是一个很好的示范。

"6 digits after the decimal point" is nonesnse, and your example is a good demonstration of this.

浮动确切的规格数据类型。

浮动的precision为 24 位。有23位表示的分数在二进制小数点后,再加上也有一个隐前导位,根据该在线来源。这使总24显著位。

The precision of the float is 24 bits. There are 23 bits denoting the fraction after the binary point, plus there's also an "implicit leading bit", according to the online source. This gives 24 significant bits in total.

因此​​,在十进制数字这大约是:

Hence in decimal digits this is approximately:

24 *日志(2)/日志(10)= 7.22

24 * log(2) / log(10) = 7.22

这篇关于用C彩车$ P​​ $ pcision的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆