round
round to integral value, regardless of rounding direction
You're viewing an older version of this page (#4018). View the current version.
Interface
#include <math.h>
double round ( double x )
long roundl ( long double x )
float roundf ( float x )
long lround ( double x )
long lroundl ( long double x )
long lroundf ( float x )
long llround ( double x )
long llroundl ( long double x )
long llroundf ( float x )
Description
The round functions return the integral value nearest to x rounding half-way cases away from zero, regardless of the current rounding direction.
The lround and llround functions return the integral value nearest to x (rounding half-way cases away from zero, regardless of the current rounding direction) in the return formats specified. If the rounded value is outside the range of the return type, the numeric result is unspecified and the invalid floating-point exception is raised. A range error may occur if the magnitude of x is too large.
Special Values
round ( ±0 ) returns ±0.
round ( ±∞ ) returns ±∞.
The round functions may, but are not required to, raise the inexact floating-point exception for non-integer numeric arguments.
The lround and llround functions need not raise the inexact floating-point exception for non-integer arguments that round to within the range of the return type.
See Also
Standards
The round, lround and llround functions conform to ISO/IEC 9899:1999(E).