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

NAME

6       nearbyint, nearbyintf, nearbyintl - floating-point rounding functions
7

SYNOPSIS

9       #include <math.h>
10
11       double nearbyint(double x);
12       float nearbyintf(float x);
13       long double nearbyintl(long double x);
14
15

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

57       None.
58

APPLICATION USAGE

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

RATIONALE

65       None.
66

FUTURE DIRECTIONS

68       None.
69

SEE ALSO

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