Re: 1.0d0 stored as integer?



David Gunter wrote:

I am trying to come up with an explanation for the following behavior. Setting a real*8 variable to 1.0d0 somehow creates a memory allocation in which only the single digit "1" is stored. Can anyone explain why?

This question doesn't sound right. A real*8 variable normally
holds a binary floating point value. The question should not
be what is 'stored' in the variable, but how that value is displayed.

The standard includes some rules related to formatted and
list directed output, but those likely don't apply to
output from debuggers.

Actually, I believe that even when running Fortran object programs
gdb uses C printf output formatting. Most likely it used %g,
C's implementation of Fortran's G format descriptor, which doesn't
print trailing zeros or trailing decimal points. The default
precision specifier for %f, %e, and %g is 6. (This is true
for single or double, as all are converted to double before
the call to printf.) You might find that you get 1 even for
values that aren't exactly 1, but close, such as 1.000001.

-- glen

.