By default, HP Fortran 90 evaluates all
floating-point constants as single-precision. For example, the
compiler treats following constant
as though you had specified:
Although the loss of precision might
be acceptable when assigning to single-precision variables, it is
might be less acceptable when assigning to double-precision variables
or when using floating-point constants in expressions where the
loss in precision might result in significant round-off differences.
 |
 |  |
 |
 | NOTE: HP Fortran 90 provides two ways to
override the default precision of individual constants: the kind
parameter and the exponent form. The kind parameter indicates the
precision of floating-point constants: 4 for single-precision,
8 for double-precision, and 16 for quad-precision. |
 |
 |  |
 |
In the following example, the kind parameter _8
specifies that the constant is to be evaluated as double-precision:
To change the precision of all floating-point constants (except
those having a kind parameter), you can use the +real_constant
option. This option takes two forms, +real_constant=double
and +real_constant=single,
which specify (respectively) double-precision and single-precision
for floating-point constants in the files compiled with this option.
The +real_constant=single
form is the default. Neither form of the option has any affect
on constants that have the kind parameter.
To promote all floating-point constants in the source files
x.f, y.f,
and z.f, compile with the command
line:
$ f90
+real_constant=double x.f y.f z.f |
The +real_constant=single
option specifies that all floating-point constants in a file are
to be treated as single-precision (the default). The following
command line specifies single-precision for all floating-point constants
in the files a.f, b.f,
and c.f:
$ f90
+real_constant=single a.f b.f c.f |
Note that +real_constant=single
does not demote constants that use either the kind parameter or
the exponent form (for example, 4.0D0).
For information about increasing the precision of variables,
see “Increasing default data sizes”. The HP
Fortran 90 Programmer's Reference describes the syntax
of the kind parameter and the exponent form and the +real_constant
option. For detailed information about how floating-point arithmetic
is implemented on HP 9000 computers and how floating-point behavior
affects the programmer, refer to the HP-UX Floating-Point
Guide.