lround(), llround()

Rounds to an integral value.

  #include <math.h>
  
  long int lround(double x);
  
  long int lroundf(float x);
  
  long int lroundl(long double x);
  
  long long int llround(double x);
  
  long long int llroundf(float x);
  
  long long int llroundl(long double x);    
Parameter

x

The value to be rounded.

Remarks

These functions round x to the neareset integer value. These functions ignore the current rounding direction; halfway values are rounded away from zero.

Unlike round(), these functions return their results as values of integer type.

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

#include <math.h>

#include <stdio.h>

int main(void)

{

double x = 2.4;

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

return 0;

}

Output:

round(2.400000) = 2.000000