FORTRAN 77 Language Reference

Octal and Hex Output

A WRITE, with the O or Z field descriptors in the FORMAT, writes out values as octal or hexadecimal integers, respectively. It writes to a field that is w characters wide, right-justified.

Example: Hex output:


	M = 161 
	WRITE ( *, 8 ) M 
8 	FORMAT ( Z3 ) 
	END

The program above displays A1 (161 decimal = A1 hex):


¤A1 

The letter A appears in output column 2.

Further examples are included in the following table.

Table 5-7 Sample Octal/Hex Output Value

Format 

Internal (Decimal) Value  

External (Octal/Hex) Representation 

O6 O2 O4.3 O4.4 O632767 14251 27 27 -32767 D77777 ** D033 0033 *****
Z4 Z3.3 Z6.4 Z532767 2708 2708 -32767 7FFF A94 DD0A94 ******

The general rules for octal and hex output are: