Next: , Previous: ALLOCATED, Up: Intrinsic Procedures


8.13 ANINT — Nearest whole number

Description:
ANINT(X [, KIND]) rounds its argument to the nearest whole number.
Option:
f95, gnu
Class:
elemental function
Syntax:
X = ANINT(X) X = ANINT(X, KIND)
Arguments:

X The type of the argument shall be REAL(*).
KIND (Optional) KIND shall be a scalar integer initialization expression.

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 will be given by KIND. If X is greater than zero, then ANINT(X) returns AINT(X+0.5). If X is less than or equal to zero, then return AINT(X-0.5).
Example:
          program test_anint
            real(4) x4
            real(8) x8
            x4 = 1.234E0_4
            x8 = 4.321_8
            print *, anint(x4), dnint(x8)
            x8 = anint(x4,8)
          end program test_anint
     

Specific names:

Name Argument Return type Option
DNINT(X) REAL(8) X REAL(8) f95, gnu