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

NAME

6       rint, rintf, rintl - round-to-nearest integral value
7

SYNOPSIS

9       #include <math.h>
10
11       double rint(double x);
12       float rintf(float x);
13       long double rintl(long double x);
14
15

DESCRIPTION

17       These  functions shall return the integral value (represented as a dou‐
18       ble) nearest x in the direction of the current rounding mode. The  cur‐
19       rent rounding mode is implementation-defined.
20
21       If  the  current  rounding  mode  rounds toward negative infinity, then
22       rint() shall be equivalent to floor() . If the  current  rounding  mode
23       rounds  toward  positive  infinity,  then rint() shall be equivalent to
24       ceil() .
25
26       These functions differ from the nearbyint(), nearbyintf(), and  nearby‐
27       intl() functions only in that they may raise the inexact floating-point
28       exception if the result differs in value from the argument.
29
30       An application wishing to check for error situations should  set  errno
31       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
32       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
33       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
34       occurred.
35

RETURN VALUE

37       Upon successful completion, these functions shall  return  the  integer
38       (represented  as  a double precision number) nearest x in the direction
39       of the current rounding mode.
40
41       If x is NaN, a NaN shall be returned.
42
43       If x is ±0 or ±Inf, x shall be returned.
44
45       If the correct value would cause overflow, a range  error  shall  occur
46       and  rint(),  rintf(),  and rintl() shall return the value of the macro
47       ±HUGE_VAL, ±HUGE_VALF, and  ±HUGE_VALL  (with  the  same  sign  as  x),
48       respectively.
49

ERRORS

51       These functions shall fail if:
52
53       Range Error
54              The result would cause an overflow.
55
56       If  the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
57       then errno  shall  be  set  to  [ERANGE].  If  the  integer  expression
58       (math_errhandling  &  MATH_ERREXCEPT)  is  non-zero,  then the overflow
59       floating-point exception shall be raised.
60
61
62       The following sections are informative.
63

EXAMPLES

65       None.
66

APPLICATION USAGE

68       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
69       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
70       at least one of them must be non-zero.
71

RATIONALE

73       None.
74

FUTURE DIRECTIONS

76       None.
77

SEE ALSO

79       abs() , ceil() , feclearexcept() , fetestexcept() , floor() , isnan() ,
80       nearbyint() , the Base Definitions volume of IEEE Std 1003.1-2001, Sec‐
81       tion 4.18, Treatment of Error Conditions  for  Mathematical  Functions,
82       <math.h>
83
85       Portions  of  this text are reprinted and reproduced in electronic form
86       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
87       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
88       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
89       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
90       event of any discrepancy between this version and the original IEEE and
91       The  Open Group Standard, the original IEEE and The Open Group Standard
92       is the referee document. The original Standard can be  obtained  online
93       at http://www.opengroup.org/unix/online.html .
94
95
96
97IEEE/The Open Group                  2003                              RINT(P)
Impressum