加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

为什么numpy的float128只有63位尾数?

发布时间:2020-12-17 17:39:24 所属栏目:Python 来源:网络整理
导读:这个问题已经在这里有了答案:????????????????????????What is the internal precision of numpy.float128?????????????????????????????????????2个 我确定这是一个愚蠢的问题,但我确实感到困惑: import numpy as np f1,f2,f64 = map(np.float128,(1,2,-6

这个问题已经在这里有了答案:????????????>????????????What is the internal precision of numpy.float128?????????????????????????????????????2个
我确定这是一个愚蠢的问题,但我确实感到困惑:

>>> import numpy as np
>>> 
>>> f1,f2,f64 = map(np.float128,(1,2,-64))
>>> f1 + f2**f64 == f1
True

或更直接地:

>>> np.finfo(np.float128).nmant
63

指数似乎有15位,那么所有那些缺失的位在哪里?

最佳答案
阅读the docs:

np.longdouble is padded to the system default; np.float96 and
np.float128 are provided for users who want specific padding. In spite
of the names,np.float96 and np.float128 provide only as much
precision as np.longdouble,that is,80 bits on most x86 machines and
64 bits in standard Windows builds.

因此看来它实际上并不会使用所有这些位.我想,如果我们假设在x86架构上有80位(我也有),它不会考虑缺少的两位,即15 63 = 78.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读