Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

INT

Elemental Intrinsic Function (Generic): Converts a value to integer type.

result = INT (a[,kind])

a

(Input) Must be of type integer, real, or complex, or a binary, octal, or hexadecimal literal constant.

kind

(Input; optional) Must be a scalar integer constant expression.

Results

The result type is integer. If kind is present, the kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent the result value in the kind of the result, the result is undefined.

Functions that cause conversion of one data type to another type have the same effect as the implied conversion in assignment statements.

The result value depends on the type and absolute value of a as follows:

  • If a is of type integer, INT(a) = a.

  • If a is of type real and | a | < 1, INT(a) has the value zero.

    If a is of type real and | a | >=1, INT(a) is the integer whose magnitude is the largest integer that does not exceed the magnitude of a and whose sign is the same as the sign of a.

  • If a is of type complex, INT(a) is the value obtained by applying the preceding rules (for a real argument) to the real part of a.

  • If a is a binary, octal, or hexadecimal literal constant, the value of the result is the value whose bit sequence according to the model in Bit Model is the same as that of a as modified by padding or truncation according to the following:

    • If the length of the sequence of bits specified by a is less than the size in bits of a scalar variable of the same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant is treated as if it were extended to a length equal to the size in bits of the result by padding on the left with zero bits.

    • If the length of the sequence of bits specified by a is greater than the size in bits of a scalar variable of the same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant is treated as if it were truncated from the left to a length equal to the size in bits of the result.

Specific Name 1

Argument Type

Result Type

INTEGER(1), INTEGER(2), INTEGER(4)

INTEGER(4)

INTEGER(1), INTEGER(2), INTEGER(4),

INTEGER(8)

INTEGER(8)

IJINT

INTEGER(4)

INTEGER(2)

IIFIX2

REAL(4)

INTEGER(2)

IINT

REAL(4)

INTEGER(2)

If the argument is a binary, octal, or hexadecimal constant, the result is affected by the assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the argument is treated as a signed integer and the bits are converted.

Example

INT (-4.2) has the value -4.

INT (7.8) has the value 7.