postfix 'd+0' in Fortran real literal expressions

后端 未结 1 1047
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 19:59

Does anyone knwow what the postfix \"d+0\" means in the assignments to M1, M2 and M4 below or is there any resource on the web or a book where one is very likel

1条回答
  •  再見小時候
    2021-01-21 20:44

    It means "double precision" and the +0 means 10 to the zeroth power (zero is the exponent).

    Here's a quote from first reference I could find:

    A number stored in a computer is limited in magnitude and precision. The limits depend on the particular computer. Thus, a REAL number has only a certain number of significant digits. If more significant digits are required for a calculation, then DOUBLE PRECISION numbers must be used. A DOUBLE PRECISION constant is written in the same exponential form as a single precision REAL constant except with a D instead of an E separating the mantissa from the exponent.

    And here is a quote from a better reference, www.fortran.com, specifically the F77 standard.

    4.5.2 Double Precision Constant.

    The forms of a double precision constant are:

    1. Basic real constant followed by a double precision exponent
    2. Integer constant followed by a double precision exponent

    The value of a double precision constant is the product of the constant that precedes the D and the power of ten indicated by the integer following the D. The integer constant part of form (2) may be written with more digits than a processor will use to approximate the value of the constant.

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