问题
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.
Then, in the most upvoted answer to how to declare variable type, C style in python, use of typing is suggested.
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))
But still, the result is :
<class 'int'>
So, How can I define np.float128 type variable in python?
回答1:
Have you tried the following?
from numpy import float128
n=float128(10000)
print(type(n))
Print:
<class '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.
来源:https://stackoverflow.com/questions/63289402/how-to-define-np-float128-variable-in-python