延长双精度 [英] Extended double precision

查看:150
本文介绍了延长双精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 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 using quadruple? If it is possible, does it depend on compiler or something else? Because I know someone said he was working with double 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 than real. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆