延长双精度 [英] Extended double precision
问题描述
是否可以使用 double
精度获取超过16位的数字,而不使用 quadruple
?如果可能,它是否依赖于编译器或别的东西?因为我知道有人说他正在使用 double
precision,具有22位精度。
数据类型 double precision
来自Fortran 77,而且该类型的唯一要求是比 / code>。您不应该再使用。
在Fortran 90/95及更高版本中,至少支持两种尺寸的实数。该精度取决于 kind
参数,其值取决于编译器。
real(kind = 8):: a,b
要有便携式定义精度,您可以通过使用以下方式获得允许一定精度的类型
值:
integer,parameter :: long_double = SELECTED_REAL_KIND(22)
那么你可以声明你的变量为
real(kind = long_double):: a,b
pre>
但不确定您的编译器将支持该精度,在这种情况下,
SELECTED_REAL_KIND
函数将返回负数。
另见这篇文章< a>
Is it possible to obtain more than 16 digits with
double
precision without usingquadruple
? If it is possible, does it depend on compiler or something else? Because I know someone said he was working withdouble
precision and had 22 digit precision.解决方案The data type
double precision
stems from Fortran 77, and the only requirement for that type is that is has more precision thanreal
. You shouldn't use that any more.In Fortran 90/95 and beyond, at least two sizes of real numbers are supported. The precision is determined by the
kind
parameter, of which the value depends on the compiler.real(kind=8) :: a, b
To have a portable way of defining precision, you can obtain a
kind
value that allows a certain precision by using:integer, parameter :: long_double = SELECTED_REAL_KIND(22)
then you can declare your variables as
real(kind=long_double) :: a, b
but it is not certain your compiler will support that precision, in which case the
SELECTED_REAL_KIND
function will return a negative number.see also this post
这篇关于延长双精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!