# Fortran Wiki int

## Description

Convert to integer type

## Standard

FORTRAN 77 and later

## Class

Elemental function

## Syntax

result = int(a [, kind))

## Arguments

• a - Shall be of type integer, real, or complex.
• kind - (Optional) An integer initialization expression indicating the kind parameter of the result.

## Return value

These functions return a integer variable or array under the following rules:

1. If a is of type integer, int(a) = a

2. If a is of type real and $|a| \lt 1$, int(a) equals 0. If $|a| \geq 1$, then int(a) equals the largest integer that does not exceed the range of a and whose sign is the same as the sign of a.

3. If a is of type complex, rule 2 is applied to the real part of a.

## Example

program test_int
integer :: i = 42
complex :: z = (-3.7, 1.0)
print *, int(i)
print *, int(z), int(z,8)
end program

category: intrinsics