Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
833 views
in Technique[技术] by (71.8m points)

numpy - Cannot use 128bit float in Python on 64bit architecture

I checked the size of a pointer in my python terminal (in Enthought Canopy IDE) via

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

I've a 64bit architecture and working with numpy.float64 is just fine. But I cannot use np.float128?

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

or

np.float128(1)

results in:

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

I'm running the following version:

sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Update: From the comments, it seems pointless to even have a 128 bit float on a 64 bit system.

I am using anaconda on a 64-bit Ubuntu 14.04 system with sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)

and 128 bit floats work fine:

import numpy
a = numpy.float128(3)

This might be an distribution problem. Try:

EDIT: Update from the comments:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...