1NEXTAFTER(3P)              POSIX Programmer's Manual             NEXTAFTER(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
11

NAME

13       nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
14       — next representable floating-point number
15

SYNOPSIS

17       #include <math.h>
18
19       double nextafter(double x, double y);
20       float nextafterf(float x, float y);
21       long double nextafterl(long double x, long double y);
22       double nexttoward(double x, long double y);
23       float nexttowardf(float x, long double y);
24       long double nexttowardl(long double x, long double y);
25

DESCRIPTION

27       The  functionality described on this reference page is aligned with the
28       ISO C standard. Any conflict between the  requirements  described  here
29       and  the  ISO C  standard is unintentional. This volume of POSIX.1‐2008
30       defers to the ISO C standard.
31
32       The nextafter(), nextafterf(), and nextafterl() functions shall compute
33       the  next  representable floating-point value following x in the direc‐
34       tion of y.  Thus, if y is less than x,  nextafter()  shall  return  the
35       largest   representable   floating-point   number  less  than  x.   The
36       nextafter(), nextafterf(), and nextafterl() functions shall return y if
37       x equals y.
38
39       The  nexttoward(),  nexttowardf(), and nexttowardl() functions shall be
40       equivalent to the corresponding nextafter() functions, except that  the
41       second  parameter  shall  have type long double and the functions shall
42       return y converted to the type of the function if x equals y.
43
44       An application wishing to check for error situations should  set  errno
45       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
46       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
47       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
48       occurred.
49

RETURN VALUE

51       Upon successful completion, these functions shall return the next  rep‐
52       resentable floating-point value following x in the direction of y.
53
54       If x==y, y (of the type x) shall be returned.
55
56       If  x  is finite and the correct function value would overflow, a range
57       error shall occur and ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL  (with  the
58       same sign as x) shall be returned as appropriate for the return type of
59       the function.
60
61       If x or y is NaN, a NaN shall be returned.
62
63       If x!=y and the correct function value is subnormal,  zero,  or  under‐
64       flows, a range error shall occur, and
65       the correct function value (if representable) or
66       0.0 shall be returned.
67

ERRORS

69       These functions shall fail if:
70
71       Range Error The correct value overflows.
72
73                   If  the  integer expression (math_errhandling & MATH_ERRNO)
74                   is non-zero, then errno shall be set to [ERANGE].   If  the
75                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
76                   non-zero, then the overflow floating-point exception  shall
77                   be raised.
78
79       Range Error The correct value is subnormal or underflows.
80
81                   If  the  integer expression (math_errhandling & MATH_ERRNO)
82                   is non-zero, then errno shall be set to [ERANGE].   If  the
83                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
84                   non-zero, then the underflow floating-point exception shall
85                   be raised.
86
87       The following sections are informative.
88

EXAMPLES

90       None.
91

APPLICATION USAGE

93       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
94       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
95       at least one of them must be non-zero.
96
97       When  <tgmath.h>  is included, note that the return type of nextafter()
98       depends on the generic typing deduced from both  arguments,  while  the
99       return  type  of nexttoward() depends only on the generic typing of the
100       first argument.
101

RATIONALE

103       None.
104

FUTURE DIRECTIONS

106       None.
107

SEE ALSO

109       feclearexcept(), fetestexcept()
110
111       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
112       Error Conditions for Mathematical Functions, <math.h>, <tgmath.h>
113
115       Portions  of  this text are reprinted and reproduced in electronic form
116       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
117       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
118       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
119       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
120       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
121       event of any discrepancy between this version and the original IEEE and
122       The Open Group Standard, the original IEEE and The Open Group  Standard
123       is  the  referee document. The original Standard can be obtained online
124       at http://www.unix.org/online.html .
125
126       Any typographical or formatting errors that appear  in  this  page  are
127       most likely to have been introduced during the conversion of the source
128       files to man page format. To report such errors,  see  https://www.ker
129       nel.org/doc/man-pages/reporting_bugs.html .
130
131
132
133IEEE/The Open Group                  2013                        NEXTAFTER(3P)
Impressum