C examples for math.h:lround
function
<cmath> <ctgmath> <math.h>
Returns the integer value that is nearest in value to x, with half way cases rounded away from zero.
The rounded value is returned as a value of type long int.
long int lround (double x); long int lroundf (float x); long int lroundl (long double x); long int lround (double x); long int lround (float x); long int lround (long double x); long int lround (T x);
Parameter | Description |
---|---|
x | Value to round. |
The value of x rounded to the nearest integral, casted to a value of type long int.
#include <stdio.h> #include <math.h> int main ()//from w w w.j a v a 2 s .c o m { printf ( "%ld\n", lround(2.1) ); printf ( "%ld\n", lround(3.9) ); printf ( "%ld\n", lround(-2.1) ); printf ( "%ld\n", lround(-3.0) ); return 0; }