FORTRAN 77 Language Reference

Octal and Hex Input      

A READ, with the O or Z field descriptors in the FORMAT, reads in w characters as octal or hexadecimal, respectively, and assigns the value to the corresponding member of the I/O list.

Example: Octal input, the external data field is:


654321 

The first digit in the example appears in input column 1.

The program that does the input is:


	READ ( *, 2 ) M 
2	FORMAT ( O6 ) 

The above data and program result in the octal value 654321 being loaded into the variable M. Further examples are included in the following table.

Table 5-6 Sample Octal/Hex Input Values

Format 

External Field 

Internal (Octal or Hex) Value  

O4

O4

O3

1234¤

16234

97¤¤¤

1234

1623

Error: "9" not allowed

Z5

Z5

Z4

A23DE¤

A23DEF

95.AF2

A23DE

A23DE

Error: "." not allowed

The general rules for octal and hex input are: