round(), roundf(), roundl() — Round to the nearest integer
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C99
Single UNIX Specification, Version 3 C++ TR1 C99 |
both | z/OS® V1R7
|
Format
#define _ISOC99_SOURCE
#include <math.h>
double round(double x);
float roundf(float x);
long double roundl(long double x);
C++
TR1 C99
#define _TR1_C99
#include <math.h>
float round(float x);
long double round(long double x);
General description
The round() family
of functions round x to the nearest integer,
in floating-point format and 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 |
---|---|---|
round | X | X |
roundf | X | X |
roundl | X | X |
Returned value
The round() family of functions returns the rounded integer value.
Related information
- math.h — Floating-point math functions
- ceil(), ceilf(), ceill() — Round up to integral value
- floor(), floorf(), floorl() — Round down to integral value
- llround(), llroundf(), llroundl() — Round to the nearest integer
- lrint(), lrintf(), lrintl() and llrint(), llrintf(), llrintl() — Round the argument to the nearest integer
- lround(), lroundf(), lroundl() — Round a decimal floating-point number to its nearest integer
- nearbyint(), nearbyintf(), nearbyintl() — Round the argument to the nearest integer
- trunc(), truncf(), truncl() — Truncate an integer value