apogee-software apogee compilers c & c++ & fortran 77 & fortran 90 User Manual

Page of 223
Apogee Software, Inc.
Page 94 Apogee User’s Manual
Consider the following program fragment:
DOUBLE PRECISION D1, D2, D3
D1  =  1.231
D2  =  1.232E0
D3  =  1.233D0
A strict reading of the standard would indicate that
D1
 and
D2
 should receive values that are
the same as if the program had been written:
REAL F1, F2
DOUBLE PRECISION D1, D2, D3
F1  =  1.231
D1  =  F1
F2  =  1.232E0
D2  =  F2
D3  =  1.233D0
In other words,
1.231
 and
1.232E0
 should be stored with
REAL
 accuracy, while
1.233D0
should be stored with
DOUBLE PRECISION
 accuracy.
Unfortunately, this "strict reading" behavior is not the behavior expected of most FORTRAN
compilers by most FORTRAN programmers, who would instead expect
D1
and
D2
to hold
representations of the respective constants that were accurate to full
DOUBLE PRECISION
accuracy after the assignments.  While such behavior is not given by a strict reading of the
standard, neither is it forbidden by the standard, since the standard does not give rules
governing required accuracy.  Furthermore, such behavior is more "user-friendly" in most
circumstances.
In ANSI C, the situation is reversed, because the "natural" floating point constant (i.e., one
without a special suffix) is a double precision value.
The
fltconst
 control-variable governs the stored accuracy of single precision floating point
constants.  Specifically:
-Xfltconst=0
For C, implement single precision floating point constants as indicated
by
fltconst=4
.  For FORTRAN, implement single precision floating
point constants as indicated by
fltconst=8
.
-Xfltconst=4
Implement single precision floating point constants with single
precision accuracy.
-Xfltconst=8
Implement single precision floating point constants with double
precision accuracy when they are used in a context in which the value
would be converted to double precision before being used, such as
assignment to a double precision variable, or use as one operand of an
operator whose other operand is a double precision variable, etc.
The
fltconst
 control-variable has file scope and permits values of
0
,
4
, and
8
.  The first-
default-value is
0
 and the second-default-value is
4
.