C Standard Library

C <math.h> - llround() Function



The C <math.h> llround() function rounds the specified number to a nearest integral value, rounding halfway cases away from zero, regardless of the current rounding mode and returns it as long long int type.

The lround() function is similar to this function, except it returns the result as long int type.

Syntax

long long int llround  (double x);
long long int llroundf (float x);
long long int llroundl (long double x);                 

Parameters

x Specify a value to round.

Return Value

Returns the value of x which is first rounded to nearby integral value then casted to long long int type.

Example:

In the example below, llround() function is used to round the given number.

#include <stdio.h>
#include <math.h>

int main (){

  printf("llround(10.2): %lld\n", llround(10.2));
  printf("llround(10.8): %lld\n", llround(10.8));
  printf("llround(-5.2): %lld\n", llround(-5.2));
  printf("llround(-5.8): %lld\n", llround(-5.8));
  return 0;
}

The output of the above code will be:

llround(10.2): 10
llround(10.8): 11
llround(-5.2): -5
llround(-5.8): -6

❮ C <math.h> Library