nearbyint()

Rounds off its argument to an integral value.

  #include <math.h>
  
  double nearbyint(double x);
  
  float nearbyintf(float x);
  
  long double nearbyintl(long double x);    
Parameter

x

The value to be computed.

Remarks

These functions compute the closest integer value but do not raise an inexact exception.

The argument is returned as an integral value in floating point format.

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 nearbyint() Usage

#include <math.h>

#include <stdio.h>

int main(void)

{

double x = 5.7;

printf("nearbyint(%f) = %f\n", x, nearbyint(x));

return 0;

}

Output:

nearbyint(5.700000) = 6.000000