function
<cmath> <ctgmath>
llround
long long int llround  (double x);
long long int llroundf (float x);
long long int llroundl (long double x);
 
long long int llround (double x);
long long int llround (float x);
long long int llround (long double x);
long long int llround (T x);           // additional overloads for integral types
 
 
Round to nearest and cast to long long integer
Returns the integer value that is nearest in value to x, with halfway cases rounded away from zero.
The rounded value is returned as a value of type long long int. See lround for an equivalent function that returns a long int instead.
Header 
<tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath>) for the 
integral types: These overloads effectively cast 
x to a 
double before calculations (defined for 
T being any 
integral type).
 
 
Parameters
- x
- Value to round.
Example
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | /* llround example */
#include <stdio.h>      /* printf */
#include <math.h>       /* lround */
int main ()
{
  printf ( "llround (2.3) = %lld\n", llround(2.3) );
  printf ( "llround (3.8) = %lld\n", llround(3.8) );
  printf ( "llround (-2.3) = %lld\n", llround(-2.3) );
  printf ( "llround (-3.8) = %lld\n", llround(-3.8) );
  return 0;
}
 | 
Possible output:
| 
Rounding using to-nearest rounding:
llround (2.3) = 2
llround (3.8) = 4
llround (-2.3) = -2
llround (-3.8) = -4
 | 
See also
- llrint
- Round and cast to long long integer (function
)
- round
- Round to nearest (function
)
- lround
- Round to nearest and cast to long integer (function
)
- nearbyint
- Round to nearby integral value (function
)
- floor
- Round down value (function
)
- ceil
- Round up value (function
)
- trunc
- Truncate value (function
)