RoundRealToNearestInteger

RoundRealToNearestInteger (double inputRealNumber);

Purpose

Rounds its floating-point argument and returns the result as a long integer. A value with a fractional part of exactly 0.5 is rounded to the nearest even number.

Example

long n;
n = round (1.2); /* result: 1L */
n = round (1.8); /* result: 2L */
n = round (1.5); /* result: 2L */
n = round (0.5); /* result: 0L */
n = round (-1.2); /* result: -1L */
n = round (-1.8); /* result: -2L */
n = round (-1.5); /* result: -2L */
n = round (-0.5); /* result: 0L */

Parameters

Input
Name Type Description
inputRealNumber double-precision Real number to round.

Return Value

Name Type Description
nearestInteger long The integer nearest to the value of the real number.