Returns the argument rounded to an integer value.
Include
<math.h>
Prototype
long double roundl(long double x);
Argument
x
Return Value
Returns the value of x
rounded to the nearest integer
value, always rounding midway cases away from zero. The rounded integer is returned as a
floating-point value.
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
long double x, y;
x = 10.103;
y = roundl(x);
printf("The nearest integer value to %Lf is %Lf\n", x, y);
x = 10.5;
y = roundl(x);
printf("The nearest integer value to %Lf is %Lf\n", x, y);
}
Example Output
The nearest integer value to 10.103000 is 10.000000
The nearest integer value to 10.500000 is 11.000000