1NEXTAFTER(3) Linux Programmer's Manual NEXTAFTER(3)
2
3
4
6 nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
7 - floating-point number manipulation
8
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
16 double nexttoward(double x, long double y);
17 float nexttowardf(float x, long double y);
18 long double nexttowardl(long double x, long double y);
19
20 Link with -lm.
21
22 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
23
24 nextafter():
25 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
26 || _XOPEN_SOURCE >= 500
27 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
28 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
29 nextafterf(), nextafterl():
30 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
31 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
32 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
33 nexttoward(), nexttowardf(), nexttowardl():
34 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
35 _POSIX_C_SOURCE >= 200112L
36
38 The nextafter(), nextafterf(), and nextafterl() functions return the
39 next representable floating-point value following x in the direction of
40 y. If y is less than x, these functions will return the largest repre‐
41 sentable number less than x.
42
43 If x equals y, the functions return y.
44
45 The nexttoward(), nexttowardf(), and nexttowardl() functions do the
46 same as the corresponding nextafter() functions, except that they have
47 a long double second argument.
48
50 On success, these functions return the next representable floating-
51 point value after x in the direction of y.
52
53 If x equals y, then y (cast to the same type as x) is returned.
54
55 If x or y is a NaN, a NaN is returned.
56
57 If x is finite, and the result would overflow, a range error occurs,
58 and the functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respec‐
59 tively, with the correct mathematical sign.
60
61 If x is not equal to y, and the correct function result would be sub‐
62 normal, zero, or underflow, a range error occurs, and either the cor‐
63 rect value (if it can be represented), or 0.0, is returned.
64
66 See math_error(7) for information on how to determine whether an error
67 has occurred when calling these functions.
68
69 The following errors can occur:
70
71 Range error: result overflow
72 An overflow floating-point exception (FE_OVERFLOW) is raised.
73
74 Range error: result is subnormal or underflows
75 An underflow floating-point exception (FE_UNDERFLOW) is raised.
76
77 These functions do not set errno.
78
80 For an explanation of the terms used in this section, see
81 attributes(7).
82
83 ┌─────────────────────────────┬───────────────┬─────────┐
84 │Interface │ Attribute │ Value │
85 ├─────────────────────────────┼───────────────┼─────────┤
86 │nextafter(), nextafterf(), │ Thread safety │ MT-Safe │
87 │nextafterl(), nexttoward(), │ │ │
88 │nexttowardf(), nexttowardl() │ │ │
89 └─────────────────────────────┴───────────────┴─────────┘
91 C99, POSIX.1-2001, POSIX.1-2008. This function is defined in IEC 559
92 (and the appendix with recommended functions in IEEE 754/IEEE 854).
93
95 In glibc version 2.5 and earlier, these functions do not raise an
96 underflow floating-point (FE_UNDERFLOW) exception when an underflow
97 occurs.
98
100 nearbyint(3)
101
103 This page is part of release 4.16 of the Linux man-pages project. A
104 description of the project, information about reporting bugs, and the
105 latest version of this page, can be found at
106 https://www.kernel.org/doc/man-pages/.
107
108
109
110GNU 2017-09-15 NEXTAFTER(3)