Name
nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl
- round to nearest integer
Library
libm.lib
Synopsis
|
double
nearbyint (double x);
|
|
float
nearbyintf (float x);
|
|
long double
nearbyintl (long double x);
|
|
long double
rintl (long double x);
|
Return values
x
is integral or infinite,
x
itself is returned.
Detailed description
The
rint
and
rintf
functions return the integral value nearest to
x
according to the prevailing rounding mode.
The
nearbyint
and
nearbyintf
functions perform the same operation.
The functions
nearbyintl
and
rintl
are aliases to the functions
nearbyint
and
rint
respectively.
Examples
#include <math.h>
int main( )
{
double inp = 1.5;
double y;
y = nearbyint( inp );
printf( "nearbyint(%f ) = %f\n", inp, y );
y = nearbyintf( inp );
printf( "nearbyintf(%f ) = %f\n", inp, y );
y = nearbyintl( inp );
printf( "nearbyintl(%f ) = %f\n\n", inp, y );
y = rint( inp );
printf( "rint(%f ) = %f\n", inp, y );
y = rintf( inp );
printf( "rintf(%f ) = %f\n", inp, y );
y = rintl( inp );
printf( "rintl(%f ) = %f\n\n", inp, y );
}
Output
nearbyint ( 1.5 ) = 2.000000
nearbyintf ( 1.5 ) = 2.000000
nearbyintl ( 1.5 ) = 2.000000
rint ( 1.5 ) = 2.000000
rintf( 1.5 ) = 2.000000
rintl( 1.5 ) = 2.000000
See also
abs,
ceil,
fabs,
floor,
ieee,
lrint,
lround,
math,
round
Feedback
For additional information or queries on this page send feedback
© 2005-2007 Nokia
|
|