1ROUND(3)                   Linux Programmer's Manual                  ROUND(3)
2
3
4

NAME

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

SYNOPSIS

9       #include <math.h>
10
11       double round(double x);
12       float roundf(float x);
13       long double roundl(long double x);
14
15       Compile with -std=c99; link with -lm.
16

DESCRIPTION

18       These functions round x to the nearest integer, but round halfway cases
19       away from zero (regardless of the current rounding direction),  instead
20       of to the nearest even integer like rint().
21

RETURN VALUE

23       The  rounded  integer  value. If x is integral or infinite, x itself is
24       returned.
25

ERRORS

27       No errors other than EDOM and ERANGE can occur.  If x is NaN, then  NaN
28       is returned and errno may be set to EDOM.
29

NOTES

31       POSIX.1-2001  contains  text  about  overflow (which might set errno to
32       ERANGE, or raise an exception).  In practice, the result  cannot  over‐
33       flow  on any current machine, so this error-handling stuff is just non‐
34       sense.  (More precisely, overflow can  happen  only  when  the  maximum
35       value of the exponent is smaller than the number of mantissa bits.  For
36       the IEEE-754 standard 32-bit and 64-bit floating point numbers the max‐
37       imum  value of the exponent is 128 (resp. 1024), and the number of man‐
38       tissa bits is 24 (resp. 53).)
39

CONFORMING TO

41       C99.
42

SEE ALSO

44       ceil(3), floor(3), lround(3), nearbyint(3), rint(3), trunc(3)
45
46
47
48                                  2001-05-31                          ROUND(3)
Impressum