C Math llround() Function
Example
Round numbers to the nearest long long integer:
printf("%lld\n", llround(2.4));
printf("%lld\n", llround(2.5));
printf("%lld", llround(-2.5));
Definition and Usage
The llround() function rounds a number to the nearest integer, and returns it as a long long (an integer type that can store very big numbers).
Halfway cases are rounded away from zero, so 2.5 becomes 3, and -2.5 becomes -3.
The llround() function is defined in the <math.h> header file.
Tip: round() rounds in the same way, but returns a double.
Syntax
long long llround(double x);
There are also versions for float and long double values: llroundf() and llroundl().
Parameter Values
| Parameter | Description |
|---|---|
| x | Required. The number to round. |
Technical Details
| Returns: | A long long value with the rounded number. |
|---|
Related Pages
Read more about math in our C Math Tutorial.