8.13 AINT — Truncate to a whole number

Synopsis:

RESULT = AINT(A [, KIND])

Description:

AINT(A [, KIND]) truncates its argument to a whole number.

Class:

Elemental function

Arguments:
AThe type of the argument shall be REAL.
KIND(Optional) A scalar INTEGER constant expression indicating the kind parameter of the result.
Return value:

The return value is of type REAL with the kind type parameter of the argument if the optional KIND is absent; otherwise, the kind type parameter is given by KIND. If the magnitude of X is less than one, AINT(X) returns zero. If the magnitude is equal to or greater than one then it returns the largest whole number that does not exceed its magnitude. The sign is the same as the sign of X.

Example:
program test_aint
  real(4) x4
  real(8) x8
  x4 = 1.234E0_4
  x8 = 4.321_8
  print *, aint(x4), dint(x8)
  x8 = aint(x4,8)
end program test_aint
Specific names:
NameArgumentReturn typeStandard
AINT(A)REAL(4) AREAL(4)Fortran 77 and later
DINT(A)REAL(8) AREAL(8)Fortran 77 and later
Standard:

Fortran 77 and later