nearbyint() function in C++
The nearbyint() function is defined in cmath header file. This function round off the given value to a nearby integral value by using the current rounding method. The current rounding method is described by fegetround.
float nearbyint(float x); or, double nearbyint(double x); or, long double nearbyint(long double x);
Parameters: This function accepts single parameter x which contains floating point value.
Return Value: It returns the rounded value of x to a nearby integral value by using the rounding method.
Below programs illustrate the nearbyint() function in C++:
Value of x = 2.7 Round off value of x = 3
Value of x = 3.2 Round off value of x = 3