# ANINT

Elemental Intrinsic Function (Generic): Calculates the nearest whole number.

result = ANINT (a[,kind] )

a | (Input) Must be of type real.
kind | (Input; optional) Must be a scalar integer constant expression.

## Results

The result type is real. If kind is present, the kind parameter is that specified by kind; otherwise, the kind parameter is that of a. If a is greater than zero, ANINT ( a) has the value AINT (a + 0.5); if a is less than or equal to zero, ANINT (a) has the value AINT (a - 0.5).

Specific Name | Argument Type | Result Type
--- | --- | ---
ANINT 1 | REAL(4) | REAL(4)
DNINT 1 | REAL(8) | REAL(8)
QNINT | REAL(16) | REAL(16)
1The setting of compiler options specifying real size can affect ANINT and DNINT.

To truncate rather than round, use AINT.

## Example

ANINT (3.456) has the value 3.0.

ANINT (-2.798) has the value -3.0.

Consider the following:

           REAL r1, r2
           r1 = ANINT(2.6)     ! returns the value 3.0
           r2 = ANINT(-2.6)    ! returns the value -3.0

    ! Calculates and adds tax to a purchase amount.
           REAL amount, taxrate, tax, total
           taxrate = 0.081
           amount = 12.99
           tax = ANINT (amount * taxrate * 100.0) / 100.0
           total = amount + tax
           WRITE (*, 100) amount, tax, total
      100  FORMAT ( 1X, 'AMOUNT', F7.2 /
          + 1X, 'TAX ', F7.2 /
          + 1X, 'TOTAL ', F7.2)
           END

Parent topic: A to B

## See Also

NINT