FORTRAN 77 Language Reference

D Editing

The D specifier is for the exponential form of decimal double-precision items. The general form is

D [ w [ .d
 ] ] 


The D w and D w.d edit specifiers indicate that the field to be edited occupies w positions. d indicates that the fractional part of the number (the part to the right of the decimal point) has d digits. However, if the input datum contains a decimal point, that decimal point overrides the d value.

On input, the specified list item becomes defined with a real datum. On output, the specified list item must be defined as a real datum.

In an output statement, the D edit descriptor does the same thing as the E edit descriptor, except that a D is used in place of an E. The output field for the D w.d edit specifier has the width w. The value is right-justified in that field. The field consists of zero or more leading blanks followed by either a minus if the value is negative, or an optional plus, followed by the magnitude of the value of the list item rounded to d decimal digits.

w must allow for a minus sign, at least one digit to the left of the decimal point, the decimal point, and d digits to the right of the decimal point. Therefore, it must be the case that w d+3.

Example: Real input with D editing in the program, Dinp.f:

	CHARACTER LINE*24 / '12345678 23.5678 .345678' / 
	READ( LINE, '( D8.3, D8.3, D8.3 )') R, S, T 
	PRINT '( D10.3, D11.4, D13.6 )', R, S, T 

The above program displays:

0.123D+05 0.2357D+02 0.345678D+00 

In the above example, the first input data item has no decimal point, so D8.3 determines the decimal point. The other input data items have decimal points, so those decimal points override the D edit descriptor as far as decimal points are concerned.

Example: Real output with D editing in the program Dout.f:

	R = 1234.678 
	PRINT 1, R, R, R 
1	FORMAT( D9.3 / D8.4 / D13.4 ) 

The above program displays:


In the above example, the second printed line is asterisks because the D8.4 does not allow for the sign; in the third printed line the D13.4 results in three leading blanks.