gpt4 book ai didi

python - 不能在 64 位架构的 Python 中使用 128 位 float

转载 作者:太空狗 更新时间:2023-10-29 19:30:03 37 4
gpt4 key购买 nike

我检查了我的 python 终端中指针的大小(在 Enthought Canopy IDE 中)通过

import ctypes
print (ctypes.sizeof(ctypes.c_voidp) * 8)

我有一个 64 位架构,使用 numpy.float64 就好了。但是我不能使用 np.float128 吗?

np.array([1,1,1],dtype=np.float128)

np.float128(1)

结果:

AttributeError: 'module' object has no attribute 'float128'

我正在运行以下版本:

sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)

最佳答案

更新:从评论来看,在 64 位系统上使用 128 位 float 似乎毫无意义。

我在 64 位 Ubuntu 14.04 系统上使用 anacondasys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)

和 128 位 float 工作正常:

import numpy
a = numpy.float128(3)

这可能是一个分布问题。尝试:

编辑:评论更新:

Not my downvote, but this post doesn't really answer the "why doesn't np.float128 exist on my machine" implied question. The true answer is that this is platform specific: float128 exists on some platforms but not others, and on those platforms where it does exist it's almost certainly simply the 80-bit x87 extended precision type, padded to 128 bits. – Mark Dickinson

关于python - 不能在 64 位架构的 Python 中使用 128 位 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29820829/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com