本文介绍了同时在Fortran中对真实文字使用科学计数法和下划线种类说明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Fortran中使用科学的浮点文字符号很容易:

Using scientific notation for floating point literals is easy enough in Fortran:

1.5d-10

表示近似于1.5*10^-15的双精度浮点值(无论在当前的Fortran编译器设置下意味着什么).

would mean a double precision (whatever that means under current Fortran compiler settings) floating point value that approximates 1.5*10^-15.

但是,指数符号和浮点类型说明符的融合有点问题.想要一个具有C_DOUBLE类型的浮点文字时,该如何声明?

However, the fusion of the exponent notation and the floating point kind specifier is a bit of an issue. How would one declare this floating point literal when one wants it to have a type of C_DOUBLE?

我知道这是一个挑剔的问题,但是在某些情况下,双精度可能与C_DOUBLE不同.

I know that this is a bit of a nitpicking issue, but there can be circumstances when double precision will not be the same as C_DOUBLE.

推荐答案

真实的文字可以通过以下任何形式指定:

A real literal may be specified by any of the following forms:

  • 1.2
  • 1.2e0
  • 1.2d0
  • 1.2_kind
  • 1.2e0_kind
  • 1.2
  • 1.2e0
  • 1.2d0
  • 1.2_kind
  • 1.2e0_kind

最后一个例子是使用种类说明符和指数的示例.因此,针对特定的问题:1.5e-15_C_DOUBLE.

This final one is an example of using a kind specifier and an exponent. So, specific to the question: 1.5e-15_C_DOUBLE.

在某些情况下,1.5d-151.5e-15_C_DOUBLE不同.双精度和real(C_DOUBLE)的类型分别由Fortran和随附的C编译器选择.

There certainly can be cases where 1.5d-15 is not the same as 1.5e-15_C_DOUBLE. The kind of a double precision and real(C_DOUBLE) are choices by the Fortran and companion C compilers respectively.

允许通过编译器标志将单精度和双精度文字常量提升为更高种类的编译器不会触及real(C_DOUBLE).

Compilers which allow single and double precision literal constants to be promoted to higher kinds by a compiler flag won't touch real(C_DOUBLE).

这篇关于同时在Fortran中对真实文字使用科学计数法和下划线种类说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 02:10