1ROUND(P)                   POSIX Programmer's Manual                  ROUND(P)
2
3
4

NAME

6       round,  roundf, roundl - round to the nearest integer value in a float‐
7       ing-point format
8

SYNOPSIS

10       #include <math.h>
11
12       double round(double x);
13       float roundf(float x);
14       long double roundl(long double x);
15
16

DESCRIPTION

18       These functions shall round their argument to the nearest integer value
19       in  floating-point  format,  rounding  halfway  cases  away  from zero,
20       regardless of the current rounding direction.
21
22       An application wishing to check for error situations should  set  errno
23       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
24       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
25       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
26       occurred.
27

RETURN VALUE

29       Upon successful completion, these functions shall  return  the  rounded
30       integer value.
31
32       If x is NaN, a NaN shall be returned.
33
34       If x is ±0 or ±Inf, x shall be returned.
35
36       If  the  correct  value would cause overflow, a range error shall occur
37       and round(), roundf(), and roundl() shall return the value of the macro
38       ±HUGE_VAL,  ±HUGE_VALF,  and  ±HUGE_VALL  (with  the  same  sign as x),
39       respectively.
40

ERRORS

42       These functions may fail if:
43
44       Range Error
45              The result overflows.
46
47       If the integer expression (math_errhandling & MATH_ERRNO) is  non-zero,
48       then  errno  shall  be  set  to  [ERANGE].  If  the  integer expression
49       (math_errhandling & MATH_ERREXCEPT)  is  non-zero,  then  the  overflow
50       floating-point exception shall be raised.
51
52
53       The following sections are informative.
54

EXAMPLES

56       None.
57

APPLICATION USAGE

59       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
60       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
61       at least one of them must be non-zero.
62

RATIONALE

64       None.
65

FUTURE DIRECTIONS

67       None.
68

SEE ALSO

70       feclearexcept()  ,  fetestexcept()  ,  the  Base  Definitions volume of
71       IEEE Std 1003.1-2001, Section 4.18, Treatment of Error  Conditions  for
72       Mathematical Functions, <math.h>
73
75       Portions  of  this text are reprinted and reproduced in electronic form
76       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
77       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
78       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
79       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
80       event of any discrepancy between this version and the original IEEE and
81       The  Open Group Standard, the original IEEE and The Open Group Standard
82       is the referee document. The original Standard can be  obtained  online
83       at http://www.opengroup.org/unix/online.html .
84
85
86
87IEEE/The Open Group                  2003                             ROUND(P)
Impressum