如何在python中定义np.float128变量? [英] How to define np.float128 variable in python?
问题描述
在对问题 Python中的双精度浮点值的最高评价中?提到如果我们需要比标准浮点数更多的精度,则可以使用np.float128.但是我找不到办法.
In the most upvoted answer to the question Double precision floating values in Python? it is mentioned that we can use np.float128, if we need precision more than standard float. But I couldn't find a way to do this.
然后,在对如何声明的最高评价的答案中变量类型,Python中的C样式,建议使用键入.
Then, in the most upvoted answer to how to declare variable type, C style in python, use of typing is suggested.
但是,当我尝试使用键入将数据类型设置为整数类型值的float时,Python仍使用int数据类型.
However, when I tried to use typing to set the datatype as float for a integer type value, Python still used an int data type.
n : float=10000
print(type(n))
但是,结果仍然是:
<class 'int'>
那么,如何在python中定义np.float128类型变量?
So, How can I define np.float128 type variable in python?
推荐答案
您尝试过以下吗?
from numpy import float128
n=float128(10000)
print(type(n))
打印:
<class 'numpy.float128'>
请记住,在Windows 64位系统上使用 numpy.float128
存在一些问题(请参见
Bear in mind that there are some issues using numpy.float128
on Windows 64-bit (see numpy.float128 doesn't exist in windows, but is called from OpenGL). I have tested this code in an online Python editor.
这篇关于如何在python中定义np.float128变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!