6.11.105 llrintl Function

Returns the long double precision floating-point argument rounded to the nearest integer value.

Include

<math.h>

Prototype

long long int llrintl(long double x);

Argument

x
the value to round

Return Value

Returns the value of x rounded to the nearest integer value using the current rounding direction. The rounded valued is returned as a long long integer value, but is unspecified if the rounded value is outside the range of the return type.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
{
  long double x;
  long long int y;

  x = 10.103;
  y = llrintl(x);
  printf("The nearest integer value to %Lf is %lld\n", x, y);

  x = 10.51;
  y = llrintl(x);
  printf("The nearest integer value to %Lf is %lld\n", x, y);
}

Example Output

The nearest integer value to 10.103000 is 10
The nearest integer value to 10.510000 is 11