How to get Python long double literal?

How to get Python long double literal? I tried with

numpy.longdouble(1e309) 

and

 numpy.longdouble("1e309") 

but both of them just return inf . What would be the right way to do this?

[ EDIT ]. The answer below says that a long double is considered double in some platform. On my system, this is not the case. To show this, I tried:

 np.longdouble(2.0)**1029 

on my system (Mac OS 10.11). He returns

 5.7526180315594109047e+309 

[ EDIT2 ] Like I said, I just tried

  np.finfo(np.longdouble) 

which gives

  finfo(resolution=1e-18, min=-1.18973149536e+4932, max=1.18973149536e+4932, dtype=float128) 

in my OS. For information, my numpy version is 1.10.1.

+5
source share
1 answer

On some long double platforms, the same thing as long double is important. From the numpy documentation :

NPY_LONGDOUBLE

An enumeration value for a floating platform that is not less than NPY_DOUBLE, but greater on many platforms.

Sometimes a long double is an 80-bit float (but not 128 bits, as many people expected). You can check:

 numpy.finfo(numpy.longdouble) 

Consider also the following answers:

You can also try the following:

 n = numpy.longdouble(1e300) * 1e9 
+1
source

Source: https://habr.com/ru/post/1246722/


All Articles