1RINT(3P)                   POSIX Programmer's Manual                  RINT(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

NAME

12       rint, rintf, rintl — round-to-nearest integral value
13

SYNOPSIS

15       #include <math.h>
16
17       double rint(double x);
18       float rintf(float x);
19       long double rintl(long double x);
20

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
25       defers to the ISO C standard.
26
27       These  functions shall return the integral value (represented as a dou‐
28       ble) nearest x in the direction of the current rounding mode. The  cur‐
29       rent rounding mode is implementation-defined.
30
31       If  the  current  rounding  mode  rounds toward negative infinity, then
32       rint() shall be equivalent to floor().  If the  current  rounding  mode
33       rounds  toward  positive  infinity,  then rint() shall be equivalent to
34       ceil().  If the current rounding mode rounds towards zero, then  rint()
35       shall  be  equivalent  to trunc().  If the current rounding mode rounds
36       towards nearest, then rint() differs from round() in that halfway cases
37       are rounded to even rather than away from zero.
38
39       These  functions differ from the nearbyint(), nearbyintf(), and nearby‐
40       intl() functions only in that they may raise the inexact floating-point
41       exception if the result differs in value from the argument.
42
43       An  application  wishing to check for error situations should set errno
44       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
45       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
46       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
47       occurred.
48

RETURN VALUE

50       Upon  successful  completion,  these functions shall return the integer
51       (represented as a double precision number) nearest x in  the  direction
52       of  the  current rounding mode.  The result shall have the same sign as
53       x.
54
55       If x is NaN, a NaN shall be returned.
56
57       If x is ±0 or ±Inf, x shall be returned.
58

ERRORS

60       No errors are defined.
61
62       The following sections are informative.
63

EXAMPLES

65       None.
66

APPLICATION USAGE

68       The integral value returned by these functions need not be  expressible
69       as  an intmax_t.  The return value should be tested before assigning it
70       to an integer type to avoid the undefined results of an  integer  over‐
71       flow.
72

RATIONALE

74       None.
75

FUTURE DIRECTIONS

77       None.
78

SEE ALSO

80       abs(), ceil(), feclearexcept(), fetestexcept(), floor(), isnan(), near‐
81       byint()
82
83       The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
84       Error Conditions for Mathematical Functions, <math.h>
85
87       Portions  of  this text are reprinted and reproduced in electronic form
88       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
89       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
90       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
91       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
92       event of any discrepancy between this version and the original IEEE and
93       The  Open Group Standard, the original IEEE and The Open Group Standard
94       is the referee document. The original Standard can be  obtained  online
95       at http://www.opengroup.org/unix/online.html .
96
97       Any  typographical  or  formatting  errors that appear in this page are
98       most likely to have been introduced during the conversion of the source
99       files  to  man page format. To report such errors, see https://www.ker
100       nel.org/doc/man-pages/reporting_bugs.html .
101
102
103
104IEEE/The Open Group                  2017                             RINT(3P)
Impressum