lround(), lroundf(), lroundl() — Round a decimal floating-point number to its nearest integer

Standards

Standards / Extensions C or C++ Dependencies

C99
Single UNIX Specification, Version 3
C++ TR1 C99

both z/OS® V1R5

Format

#define _ISOC99_SOURCE
#include <math.h>

long int lround(double x);
long int lroundf(float x);
long int lroundl(long double x);
C++ TR1 C99:
#define _TR1_C99
#include <math.h>

long lround(float x); 
long lround(long double x);

General description

The lround functions round x to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding mode.
Note: The following table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.
Function Hex IEEE
lround X X
lroundf X X
lroundl X X

Returned value

The lround functions return the rounded integer value of x.

If the rounded value is outside the range of the return type, the numeric result is unspecified. A range error may occur if the magnitude of x is too large.

Related information