1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
1 |
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved |
2
by Francesco Paolo Lovergine
* Alligned to linux main manpages edition. |
2 |
.TH "RINT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" |
1
by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages. |
3 |
.\" rint |
4 |
.SH NAME |
|
5 |
rint, rintf, rintl \- round-to-nearest integral value
|
|
6 |
.SH SYNOPSIS |
|
7 |
.LP
|
|
8 |
\fB#include <math.h>
|
|
9 |
.br
|
|
10 |
.sp
|
|
11 |
double rint(double\fP \fIx\fP\fB); |
|
12 |
.br
|
|
13 |
float rintf(float\fP \fIx\fP\fB); |
|
14 |
.br
|
|
15 |
long double rintl(long double\fP \fIx\fP\fB); |
|
16 |
.br
|
|
17 |
\fP
|
|
18 |
.SH DESCRIPTION |
|
19 |
.LP
|
|
20 |
These functions shall return the integral value (represented as a |
|
21 |
\fBdouble\fP) nearest \fIx\fP in the direction of the |
|
22 |
current rounding mode. The current rounding mode is implementation-defined. |
|
23 |
.LP
|
|
24 |
If the current rounding mode rounds toward negative infinity, then |
|
25 |
\fIrint\fP() shall be equivalent to \fIfloor\fP() . If the current |
|
26 |
rounding mode rounds toward positive infinity, then \fIrint\fP() shall |
|
27 |
be |
|
28 |
equivalent to \fIceil\fP() . |
|
29 |
.LP
|
|
30 |
These functions differ from the \fInearbyint\fP(), \fInearbyintf\fP(), |
|
31 |
and \fInearbyintl\fP() |
|
32 |
functions only in that they may raise the inexact floating-point exception |
|
33 |
if the result differs in value from the argument. |
|
34 |
.LP
|
|
35 |
An application wishing to check for error situations should set \fIerrno\fP |
|
36 |
to zero and call |
|
37 |
\fIfeclearexcept\fP(FE_ALL_EXCEPT) before calling these functions. |
|
38 |
On return, if \fIerrno\fP is non-zero or |
|
39 |
\fIfetestexcept\fP(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) |
|
40 |
is non-zero, an error has occurred. |
|
41 |
.SH RETURN VALUE |
|
42 |
.LP
|
|
43 |
Upon successful completion, these functions shall return the integer |
|
44 |
(represented as a double precision number) nearest \fIx\fP |
|
45 |
in the direction of the current rounding mode. |
|
46 |
.LP
|
|
47 |
If |
|
48 |
\fIx\fP is NaN, a NaN shall be returned. |
|
49 |
.LP
|
|
50 |
If \fIx\fP is \(+-0 or \(+-Inf, \fIx\fP shall be returned. |
|
51 |
.LP
|
|
52 |
If the correct value would cause overflow, a range error shall occur |
|
53 |
and \fIrint\fP(), \fIrintf\fP(), and \fIrintl\fP() shall |
|
54 |
return the value of the macro \(+-HUGE_VAL, \(+-HUGE_VALF, and \(+-HUGE_VALL |
|
55 |
(with the same sign as \fIx\fP), |
|
56 |
respectively. |
|
57 |
.SH ERRORS |
|
58 |
.LP
|
|
59 |
These functions shall fail if: |
|
60 |
.TP 7 |
|
61 |
Range\ Error
|
|
62 |
The result would cause an overflow. |
|
63 |
.LP
|
|
64 |
If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, |
|
65 |
then \fIerrno\fP shall be set to [ERANGE]. If the |
|
66 |
integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, |
|
67 |
then the overflow floating-point exception shall be raised. |
|
68 |
.sp
|
|
69 |
.LP
|
|
70 |
\fIThe following sections are informative.\fP |
|
71 |
.SH EXAMPLES |
|
72 |
.LP
|
|
73 |
None. |
|
74 |
.SH APPLICATION USAGE |
|
75 |
.LP
|
|
76 |
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling |
|
77 |
& MATH_ERREXCEPT) are independent of |
|
78 |
each other, but at least one of them must be non-zero. |
|
79 |
.SH RATIONALE |
|
80 |
.LP
|
|
81 |
None. |
|
82 |
.SH FUTURE DIRECTIONS |
|
83 |
.LP
|
|
84 |
None. |
|
85 |
.SH SEE ALSO |
|
86 |
.LP
|
|
87 |
\fIabs\fP() , \fIceil\fP() , \fIfeclearexcept\fP() , \fIfetestexcept\fP() |
|
88 |
, \fIfloor\fP() , \fIisnan\fP() , \fInearbyint\fP() , the |
|
89 |
Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 4.18, Treatment |
|
90 |
of Error Conditions for Mathematical Functions, \fI<math.h>\fP |
|
91 |
.SH COPYRIGHT |
|
92 |
Portions of this text are reprinted and reproduced in electronic form |
|
93 |
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology |
|
94 |
-- Portable Operating System Interface (POSIX), The Open Group Base |
|
95 |
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of |
|
96 |
Electrical and Electronics Engineers, Inc and The Open Group. In the |
|
97 |
event of any discrepancy between this version and the original IEEE and |
|
98 |
The Open Group Standard, the original IEEE and The Open Group Standard |
|
99 |
is the referee document. The original Standard can be obtained online at |
|
100 |
http://www.opengroup.org/unix/online.html . |