anint(3f) - [FORTRAN:INTRINSIC:NUMERIC] Nearest whole number
result = anint(a [, kind])
anint(a [, kind]) rounds its argument to the nearest whole number.
A the type of the argument shall be REAL. KIND (optional) an INTEGER initialization expression indicating the kind parameter of the result.
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 will be given by KIND. If A is greater than zero, anint(a) returns aint(x + 0.5). If A is less than or equal to zero then it returns aint(x - 0.5).
Sample program:
program demo_anint use, intrinsic :: iso_fortran_env, only : real_kinds, & & real32, real64, real128 implicit none real(kind=real32) :: x4 real(kind=real64) :: x8 x4 = 1.234E0_real32 x8 = 4.321_real64 print *, anint(x4), dnint(x8) x8 = anint(x4,kind=real64) end program demo_anint
[[FORTRAN 77]] and later
[[Elemental procedure|Elemental function]]
anint (3) | March 11, 2021 |