INTEGER type

Standard: (F77) F90 F95 F2003 F2008 Example program


<Syntax>

INTEGER [ ( [ KIND= ] expression ) ]

The expression must be a scalar integer whose value identifies a valid kind of integer.

INTEGER*1
INTEGER*2
INTEGER*4
INTEGER*8

<Semantics>

INTEGER declares entities (variables, functions, etc.) to be integers. The KIND number determines the range and representation of the integers. The F90_KIND module contains named constants INT8, INT16, INT32 and INT64 which are convenient for specifying integers with a particular binary range. The standard intrinsic module ISO_FORTRAN_ENV also contains those constants.

The SELECTED_INT_KIND intrinsic function can be used to select an integer kind based on range requirements.

The actual kind numbers used depend on whether “sequential”, “byte” or “unique” kind numbering is being used.

Sequential Kind Numbering (default)

KIND 1 2 3 4
Name INT8 INT16 INT32 INT64
Range −128 : 127 −32768 : 32767 −231 : 231−1 −263 : 263−1

Byte Kind Numbering (-kind=byte option)

KIND 1 2 4 8
Name INT8 INT16 INT32 INT64
Range −128 : 127 −32768 : 32767 −231 : 231−1 −263 : 263−1

Unique Kind Numbering (-kind=unique option)

KIND 101 102 103 104
Name INT8 INT16 INT32 INT64
Range −128 : 127 −32768 : 32767 −231 : 231−1 −263 : 263−1

INTEGER*1, INTEGER*2, INTEGER*4 and INTEGER*8 are synonyms for INTEGER(INT8), INTEGER(INT16), INTEGER(INT32) and INTEGER(INT64) respectively. These synonyms are not standard Fortran.

<Related>

BIT_SIZE intrinsic function, CHARACTER type, COMPLEX type, Component Definition statement, DIGITS intrinsic function, HUGE intrinsic function, IMPLICIT statement, INT intrinsic function, KIND intrinsic function, LOGICAL type, RADIX intrinsic function, RANGE intrinsic function, REAL type, SELECTED_INT_KIND intrinsic function, Type Declaration statement