Intel® Fortran Compiler 17.0 Developer Guide and Reference

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]

s

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

n

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

k

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.

Integer constants are interpreted as decimal values (base 10) by default. To specify a constant that is not in base 10, use the following extension syntax:

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

s

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

base

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 value of nnn cannot be bigger than 2**31-1. The value is extended with zeroes on the left or truncated on the left to make it the correct size. A minus sign for s negates the value.

Note that compiler option integer-size can affect the KIND type parameter of INTEGER data and integer constants.

Examples

Valid Integer (base 10) Constants

0

-127

+32123

47_2

Invalid Integer (base 10) Constants

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 type for integers.

The following seven integers 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

The following seven integers 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

LOGICAL(1)X
INTEGER(1)X
X = -128                         -128                 Z'80'
X =  127                          127                 Z'7F'
X =  255                           -1                 Z'FF'

LOGICAL(2)X
INTEGER(2)X
X = 255                           255                 Z'FF'
X = -32768                     -32768                 Z'8000'
X = 32767                       32767                 Z'7FFF'
X = 65535                          -1                 Z'FFFF'

See Also