I don't have any programming experience in Fortran, but for one of my courses at school we have to translate a program from Fortran into Java. The line of code that I'm having an issue with is
295 FORMAT(1X,'Y(X) =',D25.16,' * X ',A1,D25.16,///)
I don't think the entire line is necessarily needed, but I wanted to give the whole line for some context. The part that says D25.16 has kind of thrown me off since I can't seem to find any information about this anywhere. I was originally thinking it was formatting a double precision number to be able to have 25 digits on the left side of the .(dot) and 16 digits on the right, but I can't seem to find any information on what that means and don't know if I'm for sure right or wrong about that. I was just seeing if anyone could give some insight to what that does.
The D edit descriptor is closely related to the E edit descriptor (which may be easier to find reading material about), but is distinct from the F edit descriptor mentioned in a comment.
E and D specify that the real number will be presented with an exponent. For output using E a number may be written as, say,
+0.1234e+12
For D25.16 you are correct that the number of digits after the decimal point is 16 (well, the fractional part), but it is the overall width of the field that is 25, not the number of digits to the left. [To the left is either a 0 or nothing.] The field width has contributions from the (obligatory) sign, (optional) leading 0, the (potentially optional) exponent marker, the (obligatory) exponent sign, and (at least) two exponent digits.
If there are three exponent digits then the exponent marker is missing (leading to such things as .1234+110).
There are differences between D and E:
D doesn't allow specification of the exponent width (cf., E15.5E5);D allows (but doesn't oblige) use of D as the exponent marker (instead of E).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With