3.1.1 Integer Data Types

Integer data types can be specified as follows:


Is kind 1, 2, 4, or 8.

If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified, integer constants are interpreted as follows:

Integer Constants

An integer constant is a whole number with no decimal point. It can have a leading sign and is interpreted as a decimal number.

Integer constants take the following form:

[s]n[n...][ _k]

Is a sign; required if negative (-), optional if positive (+).

Is a decimal digit (0 through 9). Any leading zeros are ignored.

Is the optional kind parameter: 1 for INTEGER(1), 2 for INTEGER(2), 4 for INTEGER(4), or 8 for INTEGER(8). It must be preceded by an underscore ( _ ).

An unsigned constant is assumed to be nonnegative.

Integers are expressed in decimal values (base 10) by default. To specify a constant that is not in base 10, use the following syntax:

[s][[base] #]nnn...

Is an optional plus (+) or minus (-) sign.

Is any constant from 2 through 36.

If base is omitted but # is specified, the integer is interpreted in base 16. If both base and # are omitted, the integer is interpreted in base 10.

For bases 11 through 36, the letters A through Z represent numbers greater than 9. For example, for base 36, A represents 10, B represents 11, C represents 12, and so on, through Z, which represents 35. The case of the letters is not significant.


The following examples show valid and invalid integer (base 10) constants:

Invalid  Explanation 
9999999999999999999   Number too large. 
3.14   Decimal point not allowed; this is a valid REAL constant. 
32,767   Comma not allowed. 
33_3   3 is not a valid kind for integers. 

The following integers (most of which are not base 10) are all assigned a value equal to 3,994,575 decimal:

I     = 2#1111001111001111001111
m     = 7#45644664
J     = +8#17171717
K     = #3CF3CF
n     = +17#2DE110
L     = 3994575
index = 36#2DM8F

You can use integer constants to assign values to data. The following table shows assignments to different data and lists the integer and hexadecimal values in the data:

Fortran Assignment    Integer Value in Data    Hexadecimal Value in Data


X = -128                         -128                 Z'80'
X =  127                          127                 Z'7F'
X =  255                           -1                 Z'FF'


X = 255                           255                 Z'FF'
X = -32768                     -32768                 Z'8000'
X = 32767                       32767                 Z'7FFF'
X = 65535                          -1                 Z'FFFF'

For More Information:

Previous Page Next Page Table of Contents