next up previous contents index
Next: Standard Data Types Up: ConstantsVariables, and Arrays Previous: ConstantsVariables, and Arrays

Data Types

  All the information processed by a digital computer is held internally in the form of binary digits or bits. Suitable collections of bits can be used to represent many different types of data including numbers and strings of characters. It is not necessary to know how the information is represented internally in order to write Fortran programs, only that there is a different representation for each type of data. The data type of each item also determines what operations can be carried out on it: thus arithmetic operations can be carried out on numbers, whereas character strings can be split up or joined together. The data type of each item is fixed when the program is written.

Fortran, with its emphasis on numerical operations, has four data types just for numbers. These are collectively known as the arithmetic data types. Arithmetic expressions can include mixtures of data types and, in most cases, automatic type conversions are provided. In other circumstances, however, especially in procedure calls, there is no provision for automatic type conversion and it is essential for data types to match exactly.

The range and precision of the arithmetic data types are not specified by the Standard: typical values are indicated below, but the only way to be sure is to check the manuals provided with your own Fortran system.

Several intrinsic functions are available to convert from one data type to another. Conversion from character strings to numbers and vice-versa can be complicated; these are best carried out with the internal file READ and WRITE statements (see section 10.3).

There are, as yet, no user-defined or structured data types in Fortran.



Mario Storti
Wed Nov 4 19:32:56 ART 1998