在 16、32 和 64 位 IEEE-754 系统中可以表示什么范围的数字? [英] What range of numbers can be represented in a 16-, 32- and 64-bit IEEE-754 systems?

查看:22
本文介绍了在 16、32 和 64 位 IEEE-754 系统中可以表示什么范围的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对浮点数的表示方式略知一二,但恐怕还不够.

I know a little bit about how floating-point numbers are represented, but not enough, I'm afraid.

一般问题是:

对于给定的精度(对于我来说,精确的小数位数以 10 为基数),对于 16 位、32 位和 64 位 IEEE-754 系统可以表示哪些数字范围?

For a given precision (for my purposes, the number of accurate decimal places in base 10), what range of numbers can be represented for 16-, 32- and 64-bit IEEE-754 systems?

具体来说,我只对精确到 +/-0.5(个位)或 +/-0.0005(千分位)的 16 位和 32 位数字的范围感兴趣.

Specifically, I'm only interested in the range of 16-bit and 32-bit numbers accurate to +/-0.5 (the ones place) or +/- 0.0005 (the thousandths place).

推荐答案

对于给定的 IEEE-754 浮点数X,如果

For a given IEEE-754 floating point number X, if

2^E <= abs(X) < 2^(E+1)

然后是从 X 到下一个最大可表示浮点数 (epsilon) 是:

then the distance from X to the next largest representable floating point number (epsilon) is:

epsilon = 2^(E-52)    % For a 64-bit float (double precision)
epsilon = 2^(E-23)    % For a 32-bit float (single precision)
epsilon = 2^(E-10)    % For a 16-bit float (half precision)

上述等式允许我们计算以下内容:

The above equations allow us to compute the following:

如果您希望精度为 +/-0.5(或 2^-1),则该数字的最大大小为 2^10.任何大于此且浮点数之间的距离大于0.5.

If you want an accuracy of +/-0.5 (or 2^-1), the maximum size that the number can be is 2^10. Any larger than this and the distance between floating point numbers is greater than 0.5.

如果您希望精度为 +/-0.0005(约 2^-11),则该数字的最大大小为 1.大于此值且浮点数之间的距离大于 0.0005.

If you want an accuracy of +/-0.0005 (about 2^-11), the maximum size that the number can be is 1. Any larger than this and the distance between floating point numbers is greater than 0.0005.

对于 单精度...

如果您希望精度为 +/-0.5(或 2^-1),则该数字的最大大小为 2^23.任何大于此且浮点数之间的距离大于0.5.

If you want an accuracy of +/-0.5 (or 2^-1), the maximum size that the number can be is 2^23. Any larger than this and the distance between floating point numbers is greater than 0.5.

如果您希望精度为 +/-0.0005(约 2^-11),则该数字的最大大小为 2^13.大于此且浮点数之间的距离大于0.0005.

If you want an accuracy of +/-0.0005 (about 2^-11), the maximum size that the number can be is 2^13. Any larger than this and the distance between floating point numbers is greater than 0.0005.

对于 双精度...

如果您希望精度为 +/-0.5(或 2^-1),则该数字的最大大小为 2^52.任何大于此且浮点数之间的距离大于0.5.

If you want an accuracy of +/-0.5 (or 2^-1), the maximum size that the number can be is 2^52. Any larger than this and the distance between floating point numbers is greater than 0.5.

如果您希望精度为 +/-0.0005(约 2^-11),则该数字的最大大小为 2^42.大于此且浮点数之间的距离大于0.0005.

If you want an accuracy of +/-0.0005 (about 2^-11), the maximum size that the number can be is 2^42. Any larger than this and the distance between floating point numbers is greater than 0.0005.

这篇关于在 16、32 和 64 位 IEEE-754 系统中可以表示什么范围的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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