[UP]


Manual Reference Pages  - nint (3)

NAME

nint(3f) - [FORTRAN:INTRINSIC:NUMERIC:TYPE] Nearest whole number

SYNTAX

result = nint(x [, kind])

DESCRIPTION

nint(x) rounds its argument to the nearest whole number.

ARGUMENTS

X The type of the argument shall be REAL.
KIND (Optional) An INTEGER initialization expression indicating the kind parameter of the result.

RETURN VALUE

Returns A with the fractional portion of its magnitude eliminated by rounding to the nearest whole number and with its sign preserved, converted to an INTEGER of the default kind.

EXAMPLE

Sample program:

    program demo_nint
    implicit none
    integer,parameter :: dp=kind(0.0d0)
      real ::  x4
      real(kind=dp) :: x8
      x4 = 1.234E0
      x8 = 4.321_dp
      print *, nint(x4), idnint(x8)
    end program demo_nint

STANDARD

[[FORTRAN 77]] and later, with KIND argument [[Fortran 90]] and later

CLASS

[[Elemental procedure|Elemental function]]

SEE ALSO

ceiling(3), floor(3)


nint (3) March 11, 2021
Generated by manServer 1.08 from 7d0ffb5f-2df1-4f3e-93af-0255ed06bee0 using man macros.