Name

round, roundf, roundl
- round to nearest integer, away from zero

Library

libm.lib

Synopsis

  #include <math.h>
  double round (double x);
  float roundf (float x);
  long double roundl (long double x);

Return values

x is integral or infinite, x itself is returned.


Detailed description

The round, roundf, and roundl functions return the nearest integral value to x; if x lies halfway between two integral values, then these functions return the integral value with the larger absolute value (i.e., they round away from zero).

Examples

#include <math.h>
int main( )
{
   double inp = 0.5;
   double y; 
   y = round( inp );
   printf( "round(%f ) = %f\n", inp,  y );
   y = roundf( inp );
   printf( "roundf(%f ) = %f\n", inp, y );
   y = roundl( inp );
   printf( "roundl(%f ) = %f\n\n", inp, y );
}

         

Output

round  ( 0.5 ) = 1.000000
roundf ( 0.5 ) = 1.000000
roundl ( 0.5 ) = 1.000000

         


See also

ceil, floor, ieee, lrint, lround, math, rint, trunc

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top