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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

89       None.
90

APPLICATION USAGE

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

RATIONALE

102       None.
103

FUTURE DIRECTIONS

105       None.
106

SEE ALSO

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