Returns the argument rounded to an integer value.
Include
<math.h>
Prototype
float nearbyintf(float x);
Argument
x
Return Value
Returns the value of x
rounded to an integer value using
the current rounding direction and without generating an exception. The rounded integer
is returned as a floating-point value.
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
float x, y;
x = 10.103;
y = nearbyintf(x);
printf("The nearest integer value to %f is %f\n", x, y);
x = 10.51;
y = nearbyintf(x);
printf("The nearest integer value to %f is %f\n", x, y);
}
Example Output
The nearest integer value to 10.103000 is 10.000000
The nearest integer value to 10.510000 is 11.000000