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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       llround, llroundf, llroundl — round to nearest integer value
14

SYNOPSIS

16       #include <math.h>
17
18       long long llround(double x);
19       long long llroundf(float x);
20       long long llroundl(long double x);
21

DESCRIPTION

23       The functionality described on this reference page is aligned with  the
24       ISO C  standard.  Any  conflict between the requirements described here
25       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
26       defers to the ISO C standard.
27
28       These  functions  shall  round  their  argument  to the nearest integer
29       value, rounding halfway cases away from zero, regardless of the current
30       rounding direction.
31
32       An  application  wishing to check for error situations should set errno
33       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
34       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
35       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
36       occurred.
37

RETURN VALUE

39       Upon  successful  completion,  these functions shall return the rounded
40       integer value.
41
42       If x is NaN, a domain error shall occur, and an  unspecified  value  is
43       returned.
44
45       If  x  is  +Inf, a domain error shall occur and an unspecified value is
46       returned.
47
48       If x is −Inf, a domain error shall occur and an  unspecified  value  is
49       returned.
50
51       If  the  correct value is positive and too large to represent as a long
52       long, an unspecified value shall be returned.  On systems that  support
53       the IEC 60559 Floating-Point option, a domain error shall occur; other‐
54       wise, a domain error may occur.
55
56       If the correct value is negative and too large to represent as  a  long
57       long,  an unspecified value shall be returned.  On systems that support
58       the IEC 60559 Floating-Point option, a domain error shall occur; other‐
59       wise, a domain error may occur.
60

ERRORS

62       These functions shall fail if:
63
64       Domain Error
65                   The  x argument is NaN or ±Inf, or the correct value is not
66                   representable as an integer.
67
68                   If the integer expression (math_errhandling  &  MATH_ERRNO)
69                   is  non-zero,  then  errno  shall be set to [EDOM].  If the
70                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
71                   non-zero,  then  the invalid floating-point exception shall
72                   be raised.
73
74       These functions may fail if:
75
76       Domain Error
77                   The correct value is not representable as an integer.
78
79                   If the integer expression (math_errhandling  &  MATH_ERRNO)
80                   is  non-zero,  then  errno  shall be set to [EDOM].  If the
81                   integer expression (math_errhandling &  MATH_ERREXCEPT)  is
82                   non-zero,  then  the invalid floating-point exception shall
83                   be raised.
84
85       The following sections are informative.
86

EXAMPLES

88       None.
89

APPLICATION USAGE

91       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
92       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
93       at least one of them must be non-zero.
94

RATIONALE

96       These functions differ from the llrint() functions in that the  default
97       rounding direction for the llround() functions round halfway cases away
98       from zero and need not raise the inexact floating-point  exception  for
99       non-integer  arguments  that  round  to  within the range of the return
100       type.
101

FUTURE DIRECTIONS

103       None.
104

SEE ALSO

106       feclearexcept(), fetestexcept(), lround()
107
108       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
109       Error Conditions for Mathematical Functions, <math.h>
110
112       Portions  of  this text are reprinted and reproduced in electronic form
113       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
114       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
115       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
116       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
117       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
118       event of any discrepancy between this version and the original IEEE and
119       The Open Group Standard, the original IEEE and The Open Group  Standard
120       is  the  referee document. The original Standard can be obtained online
121       at http://www.unix.org/online.html .
122
123       Any typographical or formatting errors that appear  in  this  page  are
124       most likely to have been introduced during the conversion of the source
125       files to man page format. To report such errors,  see  https://www.ker
126       nel.org/doc/man-pages/reporting_bugs.html .
127
128
129
130IEEE/The Open Group                  2013                          LLROUND(3P)
Impressum