1NEARBYINT(3P)              POSIX Programmer's Manual             NEARBYINT(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       nearbyint, nearbyintf, nearbyintl - floating-point rounding functions
13

SYNOPSIS

15       #include <math.h>
16
17       double nearbyint(double x);
18       float nearbyintf(float x);
19       long double nearbyintl(long double x);
20
21

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

63       None.
64

APPLICATION USAGE

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

RATIONALE

71       None.
72

FUTURE DIRECTIONS

74       None.
75

SEE ALSO

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