1NEXTAFTER(3P) POSIX Programmer's Manual NEXTAFTER(3P)
2
3
4
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
12 nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
13 - next representable floating-point number
14
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
25
27 The nextafter(), nextafterf(), and nextafterl() functions shall compute
28 the next representable floating-point value following x in the direc‐
29 tion of y. Thus, if y is less than x, nextafter() shall return the
30 largest representable floating-point number less than x. The
31 nextafter(), nextafterf(), and nextafterl() functions shall return y if
32 x equals y.
33
34 The nexttoward(), nexttowardf(), and nexttowardl() functions shall be
35 equivalent to the corresponding nextafter() functions, except that the
36 second parameter shall have type long double and the functions shall
37 return y converted to the type of the function if x equals y.
38
39 An application wishing to check for error situations should set errno
40 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
41 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
42 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
43 occurred.
44
46 Upon successful completion, these functions shall return the next rep‐
47 resentable floating-point value following x in the direction of y.
48
49 If x== y, y (of the type x) shall be returned.
50
51 If x is finite and the correct function value would overflow, a range
52 error shall occur and ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL (with the
53 same sign as x) shall be returned as appropriate for the return type of
54 the function.
55
56 If x or y is NaN, a NaN shall be returned.
57
58 If x!= y and the correct function value is subnormal, zero, or under‐
59 flows, a range error shall occur, and either the correct function value
60 (if representable) or 0.0 shall be returned.
61
63 These functions shall fail if:
64
65 Range Error
66 The correct value overflows.
67
68 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
69 then errno shall be set to [ERANGE]. If the integer expression
70 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
71 floating-point exception shall be raised.
72
73 Range Error
74 The correct value is subnormal or underflows.
75
76 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
77 then errno shall be set to [ERANGE]. If the integer expression
78 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
79 floating-point exception shall be raised.
80
81
82 The following sections are informative.
83
85 None.
86
88 On error, the expressions (math_errhandling & MATH_ERRNO) and
89 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
90 at least one of them must be non-zero.
91
93 None.
94
96 None.
97
99 feclearexcept(), fetestexcept(), the Base Definitions volume of
100 IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Conditions for
101 Mathematical Functions, <math.h>
102
104 Portions of this text are reprinted and reproduced in electronic form
105 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
106 -- Portable Operating System Interface (POSIX), The Open Group Base
107 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
108 Electrical and Electronics Engineers, Inc and The Open Group. In the
109 event of any discrepancy between this version and the original IEEE and
110 The Open Group Standard, the original IEEE and The Open Group Standard
111 is the referee document. The original Standard can be obtained online
112 at http://www.opengroup.org/unix/online.html .
113
114
115
116IEEE/The Open Group 2003 NEXTAFTER(3P)