lround function rounds the argument to the nearest long integer
Syntax
C lround function has the following syntax.
long int lroundf(float arg);
long int lround(double arg);
long int lroundl(long double arg);
Header
C lround functions are from header file math.h
.
Description
C lround functions return the value of arg rounded to the nearest long integer. Values precisely between two values, such as 3.5, are rounded up.
Example
The following code rounds the argument to the nearest long integer.
#include <math.h>
#include <stdio.h>
/*w w w . j a va2s .c o m*/
int main(void)
{
double val = 1.0;
do {
printf("%f %f\n", val, lround (val));
val++;
} while (val<11.0);
return 0;
}
The code above generates the following result.