round()

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);    
Parameter

x

The value to be rounded.

Remarks

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.

Listing: Example of round() Usage

#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