llrint - C math.h

C examples for math.h:llrint

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Rounds x to an integral value, using the rounding direction specified by fegetround, and returns it as a value of type long long int.

Prototype

long long int llrint  (double x);
long long int llrintf (float x);
long long int llrintl (long double x);
long long int llrint (float x);
long long int llrint (long double x);
long long int llrint (T x);           

Parameters

Parameter Description
x Value to round.

Return Value

The value of x rounded to a nearby integral, casted to a value of type long long int.

Example

Demo Code

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

int main ()//from   w w w .j  av  a 2  s .c o m
{
  printf ( "%lld\n", llrint(2.1) );
  printf ( "%lld\n", llrint(3.9) );
  printf ( "%lld\n", llrint(-2.1) );
  printf ( "%lld\n", llrint(-3.9) );
  return 0;
}

Related Tutorials