Using scientific notation and underscore kind specifier at the same time for real literals in Fortran

前端 未结 1 1361
抹茶落季
抹茶落季 2021-01-14 06:01

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

1.5d-10

would mean a double precision (whatever that means unde

相关标签:
1条回答
  • 2021-01-14 06:40

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

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

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

    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.

    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).

    0 讨论(0)
提交回复
热议问题