Elemental Intrinsic Function (Generic): Returns the nearest integer to the argument.
Syntax
Results:
The result is of type integer. If kind is present, the kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent the result value in the kind of the result, the result is undefined.
If a is greater than zero, NINT(a) has the value INT(a + 0.5); if a is less than or equal to zero, NINT(a) has the value INT(a - 0.5).
Specific Name | Argument Type | Result Type |
---|---|---|
ININT | REAL(4) | INTEGER(2) |
NINT 1, 2 | REAL(4) | INTEGER(4) |
KNINT | REAL(4) | INTEGER(8) |
IIDNNT | REAL(8) | INTEGER(2) |
IDNINT 2, 3 | REAL(8) | INTEGER(4) |
KIDNNT | REAL(8) | INTEGER(8) |
IIQNNT 4 | REAL(16) | INTEGER(2) |
IQNINT 2, 4 | REAL(16) | INTEGER(4) |
KIQNNT 4, 5 | REAL(16) | INTEGER(8) |
1 Or JNINT.
2 The setting of compiler option /integer_size can affect NINT, IDNINT, and IQNINT. 3 Or JIDNNT. For compatibility with older versions of Fortran, IDNINT can also be specified as a generic function. 4 VMS, U*X 5 This specific function cannot be passed as an actual argument. |
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
Examples
NINT (3.879) has the value 4.
NINT (-2.789) has the value -3.
The following shows another example:
INTEGER(4) i1, i2
i1 = NINT(2.783) ! returns 3
i2 = IDNINT(-2.783D0) ! returns -3