扩展双精度 [英] Extended double precision

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

问题描述

不使用 quadruple 是否可以得到超过 16 位的 double 精度?如果可能,它是否取决于编译器或其他东西?因为我知道有人说他使用的是 double 精度并且有 22 位精度.

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.

推荐答案

数据类型双精度源于Fortran 77,该类型的唯一要求是比真实.你不应该再使用它了.

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.

在 Fortran 90/95 及更高版本中,至少支持两种大小的实数.精度由kind参数决定,其值取决于编译器.

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

为了有一种可移植的方式来定义精度,您可以使用以下方法获得一个允许特定精度的 kind 值:

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

但不确定您的编译器是否支持该精度,在这种情况下,SELECTED_REAL_KIND 函数将返回负数.

but it is not certain your compiler will support that precision, in which case the SELECTED_REAL_KIND function will return a negative number.

另请参阅这篇文章

这篇关于扩展双精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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