Name

llrint, llrintf, llrintl, lrint, lrintf, lrintl
- round to nearest integer

Library

libm.lib

Synopsis

  #include <math.h>
  long long llrint (double x);
  long long llrintf (float x);
  long long llrintl (long double x);
  long lrint (double x);
  long lrintf (float x);
  long lrintl (long double x);

Return values


Detailed description

The lrint function returns the integer nearest to its argument x according to the current rounding mode. When the rounded result is representable as a long , the expression

The llrint, llrintf and lrintf functions differ from lrint only in their input and output types. lrintf and llrintl is just an aliases to the functions lrint (and);
llrint respectively


Examples

#include <math.h>
int main( void )
{
   double x1 = 1.4;
   long long y;
   int res ;
   y = llrint( x1 );
   printf( "llrint(%f) = %d\n", x1, y );
   y = llrintf( x1 );
   printf( "llrintf(%f) = %d\n", x1, y );
   y = llrintl( x1 );
   printf( "llrintl(%f) = %d\n", x1, y );
   res = lrint( x1 );
   printf( "lrint(%f) = %d\n", x1, res );
   res = lrintf( x1 );
   printf( "lrintf(%f) = %d\n", x1, res );
   res = lrintl( x1 );
   printf( "lrintl(%f) = %d\n", x1, res );
}

         

Output

llrint ( 1.4 ) = 1.000000
llrintf( 1.4 ) = 1.000000
llrintl( 1.4 ) = 1.000000
lrint ( 1.4 ) = 1.000000
lrintf( 1.4 ) = 1.000000
lrintl( 0.0 ) = 1.000000

         


See also

lround, math, rint, round

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top