Name

llround, llroundf, llroundl, lround, lroundf, lroundl
- round to nearest integer

Library

libm.lib

Synopsis

  #include <math.h>
  long long llround (double x);
  long long llroundf (float x);
  long long llroundl (long double x);
  long lround (double x);
  long lroundf (float x);
  long lroundl (long double x);

Return values


Detailed description

The lround function returns the integer nearest to its argument x, rounding away from zero in halfway cases. If the rounded result is too large to be represented as a long value, the return value is undefined. When the rounded result is representable as a long , the expression lround (x);
is equivalent to round (x);(long) (although the former may be more efficient).

The llround, llroundf, llroundl, lroundf and lroundl functions differ from lround only in their input and output types.


Examples

#include <math.h>
int main( void )
{
   double x1 = 1.5;
   long long y;
   int res ;
   y = llround( x1 );
   printf( "llround(%f) = %d\n", x1, y );
   y = llroundf( x1 );
   printf( "llroundf(%f) = %d\n", x1, y );
   y = llroundl( x1 );
   printf( "llroundl(%f) = %d\n\n", x1, y );
   res = lround( x1 );
   printf( "lround(%f) = %d\n", x1, res );
   res = lroundf( x1 );
   printf( "lroundf(%f) = %d\n", x1, res );
   res = lroundl( x1 );
   printf( "lroundl(%f) = %d\n", x1, res );
}

         

Output

llround ( 1.5 ) = 2.000000
llroundf( 1.5 ) = 2.000000
llroundl( 1.5 ) = 2.000000
lround ( 1.5 ) = 2.000000
lroundf( 1.5 ) = 2.000000
lroundl( 1.5 ) = 2.000000

         


See also

lrint, math, rint, round

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top