nint

Date:

02-08-2023

NAME

NINT, IDNINT, ININT, JNINT, KNINT - Convert to nearest integer

SYNOPSIS

NINT ([A=]a [,[KIND=]kind])
IDNINT ([A=]a [,[KIND=]kind])
ININT ([A=]a)
JNINT ([A=]a)
KNINT ([A=]a)

STANDARDS

Fortran

Fortran extensions: IDNINT, ININT, JNINT, KNINT

DESCRIPTION

NINT is the generic function name; the others are specifics. These are elemental intrinsic functions. They accept the following arguments:

a

Must be type real. See the RETURN VALUES section for information on input data types and return values.

kind

A scalar integer initialization expression. Must be a kind type allowed for a.

These functions find the nearest integer for real numbers, using these equations:

  • If a >= 0, y= INT(a+.5).

  • If a < 0, y= INT(a-.5).

NOTES

The NINT and IDNINT intrinsic function names can be passed as arguments; the others cannot.

Note: The nint() function has a Linux-equivalent name. Use the man -aname option to show all manual pages matching name within the MANPATH search path. Manual pages are displayed in the order found.

RETURN VALUES

NINT returns the nearest INTEGER for its REAL argument.

IDNINT returns the nearest INTEGER for its double-precision argument.

ININT returns an INTEGER(KIND=2) for its REAL argument.

JNINT returns an INTEGER(KIND=4) for its REAL argument.

KNINT returns an INTEGER(KIND=8) for its REAL argument.