C examples for math.h:lrint
function
<cmath> <ctgmath> <math.h>
Rounds x to an integral value, using the rounding direction specified by fegetround, and returns it as a value of type long int.
long int lrint (double x); long int lrintf (float x); long int lrintl (long double x); long int lrint (float x); long int lrint (long double x); long int lrint (T x);
Parameter | Description |
---|---|
x | Value to round. |
The value of x rounded to a nearby integral, casted to a value of type long int.
#include <stdio.h> #include <fenv.h> #include <math.h> int main ()//from w ww .j a v a2 s .co m { printf ( "%ld\n", lrint(2.1) ); printf ( "%ld\n", lrint(3.9) ); printf ( "%ld\n", lrint(-2.1) ); printf ( "%ld\n", lrint(-3.9) ); return 0; }