next up previous

3.2 Precision Selection     continued...

On a Sun workstation the value of P9 would be the same as DOUBLE (as defined above); on a Cray supercomputer the value of P9 would be the same as SINGLE. That is, REAL(P9) declares double precision variables on the Sun and single precision variables on the Cray. With this technique entire programs may be portably written based upon desired precision/range properties of the variables rather than upon implementation defaults for single and double real precision. This in itself is a powerful tool for numerical robustness.

Real constants of any kind can be formed by appending the kind value with an underscore to the default single precision real constants provided by the language. Thus, using the kind values defined above:

1.41_SINGLE and 1.41 are the same,
1.41_DOUBLE and 1.41D0 are the same,
1.41_IEEE is the IEEE version of 1.41,
1.41_P9 is the appropriate 9+ digit representation of 1.41, and
 typically will be equivalent to 1.41_SINGLE or 1.41_DOUBLE