C examples for math.h:rint
function
<cmath> <ctgmath> <math.h>
Rounds x to an integral value, using the rounding direction specified by fegetround.
long double rintl (long double x); long double rint (long double x); double rint (double x); float rintf (float x); float rint (float x); double rint (T x);
Parameter | Description |
---|---|
x | Value to round. |
The value of x rounded to a nearby integral as a floating-point value.
#include <stdio.h> #include <fenv.h> #include <math.h> int main ()//from w w w . j ava 2 s . co m { printf ( "rint (2.3) = %.1f\n", rint(2.1) ); printf ( "rint (3.8) = %.1f\n", rint(3.9) ); printf ( "rint (-2.3) = %.1f\n", rint(-2.1) ); printf ( "rint (-3.8) = %.1f\n", rint(-3.9) ); return 0; }