如何根据位数计算精度的十进制数字? [英] How to calculate decimal digits of precision based on the number of bits?

查看:198
本文介绍了如何根据位数计算精度的十进制数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习浮点格式(IEEE)。
在单精度浮点格式中,提到尾数有24位,所以它有6 1/2位精度的十进制数(正如理解机器一书),精度的十进制数字7.22。



I不明白如何计算精度的十进制数字。
有人可以请赐教吗?
解决方案

使用24位,假设一位为符号保留,那么您可以表示的最大十进制数是2 ^ 23-1 = 8388607。也就是说,你可以得到6位数字,有时候是7位数字。这通常表示为6 1/2位数。如果24位表示一个无符号数,那么你可以存储的最大值是2 ^ 24-1 = 16,777,215,或者7和一个小数位。

引用你一个明确的小数位,如7.22十进制数字的数字,他们正在做的是取最大值的日志(10)。所以log(16777115)= 7.22。

一般来说,从给定的位数中得到的小数位数是:

  d = log [base 10](2 ^ b)

其中b是位数,d是小数位数。然后:

  d = b * log(2)
d〜= b * .3010
code>

所以24位给出24 * .3010 = 7.224

I am learning about floating point formats (IEEE). In the single precision floating point format ,it is mentioned that the mantissa has 24 bits and so it has 6 1/2 decimal digits of precision (as the per the book "understanding the machine") , and 7.22 decimal digits of precision.

I don't understand how the decimal digits of precision is calculated. Can somebody please enlighten me ?

解决方案

With 24 bits, assuming one bit is reserved for the sign, then the largest decimal number you can represent is 2^23-1=8388607. That is, you can get 6 digits and sometimes a 7th. This is often expressed as "6 1/2 digits". If the 24 bits are representing an unsigned number, then the maximum value you can store is 2^24-1=16,777,215, or 7 and a fraction digits.

When someone quotes you a number with explicit decimal places like 7.22 decimal digits, what they're doing is taking the log (base 10) of the maximum value. So log(16777115)=7.22.

In general, the number of decimal digits you'll get from a given number of bits is:

d=log[base 10](2^b)

where b is the number of bits and d is the number of decimal digits. Then:

d=b * log(2)
d~=b * .3010

So 24 bits gives 24 * .3010 = 7.224

这篇关于如何根据位数计算精度的十进制数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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