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

NAME

6       nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
7       - next representable floating-point number
8

SYNOPSIS

10       #include <math.h>
11
12       double nextafter(double x, double y);
13       float nextafterf(float x, float y);
14       long double nextafterl(long double x, long double y);
15       double nexttoward(double x, long double y);
16       float nexttowardf(float x, long double y);
17       long double nexttowardl(long double x, long double y);
18
19

DESCRIPTION

21       The nextafter(), nextafterf(), and nextafterl() functions shall compute
22       the  next  representable floating-point value following x in the direc‐
23       tion of y.  Thus, if y is less than x,  nextafter()  shall  return  the
24       largest   representable   floating-point   number   less  than  x.  The
25       nextafter(), nextafterf(), and nextafterl() functions shall return y if
26       x equals y.
27
28       The  nexttoward(),  nexttowardf(), and nexttowardl() functions shall be
29       equivalent to the corresponding nextafter() functions, except that  the
30       second  parameter  shall  have type long double and the functions shall
31       return y converted to the type of the function if x equals y.
32
33       An application wishing to check for error situations should  set  errno
34       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
35       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
36       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
37       occurred.
38

RETURN VALUE

40       Upon successful completion, these functions shall return the next  rep‐
41       resentable floating-point value following x in the direction of y.
42
43       If x== y, y (of the type x) shall be returned.
44
45       If  x  is finite and the correct function value would overflow, a range
46       error shall occur and ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL  (with  the
47       same sign as x) shall be returned as appropriate for the return type of
48       the function.
49
50       If x or y is NaN, a NaN shall be returned.
51
52       If x!= y and the correct function value is subnormal, zero,  or  under‐
53       flows, a range error shall occur, and either the correct function value
54       (if representable) or 0.0 shall be returned.
55

ERRORS

57       These functions shall fail if:
58
59       Range Error
60              The correct value overflows.
61
62       If the integer expression (math_errhandling & MATH_ERRNO) is  non-zero,
63       then  errno  shall  be  set  to  [ERANGE].  If  the  integer expression
64       (math_errhandling & MATH_ERREXCEPT)  is  non-zero,  then  the  overflow
65       floating-point exception shall be raised.
66
67       Range Error
68              The correct value is subnormal or underflows.
69
70       If  the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
71       then errno  shall  be  set  to  [ERANGE].  If  the  integer  expression
72       (math_errhandling  &  MATH_ERREXCEPT)  is  non-zero, then the underflow
73       floating-point exception shall be raised.
74
75
76       The following sections are informative.
77

EXAMPLES

79       None.
80

APPLICATION USAGE

82       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
83       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
84       at least one of them must be non-zero.
85

RATIONALE

87       None.
88

FUTURE DIRECTIONS

90       None.
91

SEE ALSO

93       feclearexcept() , fetestexcept()  ,  the  Base  Definitions  volume  of
94       IEEE Std 1003.1-2001,  Section  4.18, Treatment of Error Conditions for
95       Mathematical Functions, <math.h>
96
98       Portions of this text are reprinted and reproduced in  electronic  form
99       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
100       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
101       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
102       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
103       event of any discrepancy between this version and the original IEEE and
104       The Open Group Standard, the original IEEE and The Open Group  Standard
105       is  the  referee document. The original Standard can be obtained online
106       at http://www.opengroup.org/unix/online.html .
107
108
109
110IEEE/The Open Group                  2003                         NEXTAFTER(P)
Impressum