Redian新闻
>
fortran 中怎样达到32位有效数字的精度?
avatar
fortran 中怎样达到32位有效数字的精度?# Computation - 科学计算
w*t
1
unix里,我用
f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
我想问,怎样达到32位有效数字的精度?
我知道好像有类似于 f77 -r16 ,90有类似的吗?
或者code的编写里面怎样设置?好像没有 real(16) 这样的?
谢谢帮助!
avatar
l*n
2

用SELECTED_REAL_KIND来定义精度
比如
db=SELECTED_REAL_KIND(2*kind(1.0))
real(dp) ::x
x就是双精度的

【在 w**t 的大作中提到】
: unix里,我用
: f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
: 我想问,怎样达到32位有效数字的精度?
: 我知道好像有类似于 f77 -r16 ,90有类似的吗?
: 或者code的编写里面怎样设置?好像没有 real(16) 这样的?
: 谢谢帮助!

avatar
f*g
3
双精度是 REAL(8),15 digits
real*8 variableName
or
implicit real*8(a-h,o-z)
都行
REAL(8) or DOUBLE PRECISION 8 15 digits
Negative numbers from approximately –1.797693134862316D+308 to –2.
225073858507201D–308
Zero
Positive numbers from approximately +2.225073858507201D–308 to +1.
797693134862316D+308

【在 w**t 的大作中提到】
: unix里,我用
: f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
: 我想问,怎样达到32位有效数字的精度?
: 我知道好像有类似于 f77 -r16 ,90有类似的吗?
: 或者code的编写里面怎样设置?好像没有 real(16) 这样的?
: 谢谢帮助!

avatar
s*t
4
you need quadruple precision. look at
http://crd.lbl.gov/~dhbailey/mpdist/

【在 w**t 的大作中提到】
: unix里,我用
: f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
: 我想问,怎样达到32位有效数字的精度?
: 我知道好像有类似于 f77 -r16 ,90有类似的吗?
: 或者code的编写里面怎样设置?好像没有 real(16) 这样的?
: 谢谢帮助!

avatar
O*e
5
If you are using a Fortran 9x compiler, see what this gives you:
print*,selected_real_kind(33,4931)
If you get a positive integer, your compiler claims to support
IEEE quad-precision real variables. If you get a negative number,
your compiler does not provide built-in support for QP.
Intel's ifort supports QP by emulation and provides QP versions
of the intrinsic functions. There is one bug that I know of in
the way QP numbers are printed--they are truncated and printed
as DP numbers, but th

【在 w**t 的大作中提到】
: unix里,我用
: f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
: 我想问,怎样达到32位有效数字的精度?
: 我知道好像有类似于 f77 -r16 ,90有类似的吗?
: 或者code的编写里面怎样设置?好像没有 real(16) 这样的?
: 谢谢帮助!

avatar
m*n
6
你需要 quadruple precision
先把你的数设定为double precision。
再到settings 里, 将Defualt Real kind 设定为8。
这样一来,编译后就是32位数精度。

【在 w**t 的大作中提到】
: unix里,我用
: f77 -r8 或 pgf90 -r8 都可以达到双精度,i.e. 16位有效数字的精度
: 我想问,怎样达到32位有效数字的精度?
: 我知道好像有类似于 f77 -r16 ,90有类似的吗?
: 或者code的编写里面怎样设置?好像没有 real(16) 这样的?
: 谢谢帮助!

avatar
h*s
7
Not all compilers support quad precision, hence the test to check the
sign of the integer returned by selected_real_kind(33,4931).

【在 m********n 的大作中提到】
: 你需要 quadruple precision
: 先把你的数设定为double precision。
: 再到settings 里, 将Defualt Real kind 设定为8。
: 这样一来,编译后就是32位数精度。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。