Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29393 Discussions

Writing numbers with large exponents

gregscvf
Beginner
819 Views
Hi,
I just came across this unique way that CVF6.6B handles output of numbers with large exponents, when using "D" Formatting. Note the way "D" is dropped in the output.
Is this to standard, or a bug? Is there a complier switch that will fix?
Greg
real xval, rval*8
rval=1.2342342323423d+28
write(*,'(1P,D20.13)')rval
write(*,'(1P,D20.13)')HUGE(rval)

rval=1.2342342323423d-28
write(*,'(1P,D20.13)')rval
write(*,'(1P,D20.13)')TINY(rval)

xval=1.2
write(*,'(1P,E20.13)')HUGE(xval)
END 

Produces this output:
 1.2342342323423D+28
 1.7976931348623+308
 1.2342342323423D-28
 2.2250738585072-308
 3.4028234663853E+38
0 Kudos
1 Reply
TimP
Honored Contributor III
819 Views
This is the way the Fortran standard has required it be done for many years, although a few compilers waited until around 1990 to implement it. I think the committee members agreed that the number of characters required for the exponent should not vary with magnitude.
Your other options include a format descriptor like E20.13E4, which requires the E to appear.
0 Kudos
Reply