Rounds to an integral value, rounding halfway values furthest from zero.
#include <math.h> double round(double x); float roundf(float x); long double roundl(long double x);
x
The value to be rounded.
These functions round x to the nearest integer value. These functions ignore the current rounding direction; halfway values are rounded away from zero.
This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.
#include <math.h> #include <stdio.h> int main(void) { double x = 2.5; printf("round(%f) = %f\n", x, round(x)); return 0; } Output: round(2.500000) = 2.000000