function
<cmath> <ctgmath>

# rint

```     double rint  (double x);
float rintf (float x);
long double rintl (long double x);
```
```     double rint (double x);
float rint (float x);
long double rint (long double x);
Round to integral value
Rounds x to an integral value, using the rounding direction specified by fegetround.

This function may raise an FE_INEXACT exception if the value returned differs in value from x. See nearbyint for an equivalent function that cannot raise such exception.

Header <tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (`<cmath>`) for the integral types: These overloads effectively cast x to a `double` before calculations (defined for T being any integral type).

x
Value to round.

### Return Value

The value of x rounded to a nearby integral (as a floating-point value).
If this value differs from x, a FE_INEXACT exception may be raised (depending on the implementation).

### Example

 ``1234567891011121314151617181920212223`` ``````/* rint example */ #include /* printf */ #include /* fegetround, FE_* */ #include /* rint */ int main () { printf ("rounding using "); switch (fegetround()) { case FE_DOWNWARD: printf ("downward"); break; case FE_TONEAREST: printf ("to-nearest"); break; case FE_TOWARDZERO: printf ("toward-zero"); break; case FE_UPWARD: printf ("upward"); break; default: printf ("unknown"); } printf (" rounding:\n"); printf ( "rint (2.3) = %.1f\n", rint(2.3) ); printf ( "rint (3.8) = %.1f\n", rint(3.8) ); printf ( "rint (-2.3) = %.1f\n", rint(-2.3) ); printf ( "rint (-3.8) = %.1f\n", rint(-3.8) ); return 0; }``````

Possible output:
 ``` Rounding using to-nearest rounding: rint (2.3) = 2.0 rint (3.8) = 4.0 rint (-2.3) = -2.0 rint (-3.8) = -4.0 ```