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(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
25 _ISOC99_SOURCE; or cc -std=c99
26 nextafterf(), nextafterl(): _BSD_SOURCE || _SVID_SOURCE ||
27 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99
28 nexttoward(), nexttowardf(), nexttowardl(): _XOPEN_SOURCE >= 600 ||
29 _ISOC99_SOURCE; cc -std=c99
30
32 The nextafter() functions return the next representable floating-point
33 value following x in the direction of y. If y is less than x, these
34 functions will return the largest representable number less than y.
35
36 If x equals y, the functions return y.
37
38 The nexttoward() functions do the same as the nextafter() functions,
39 except that they have a long double second argument.
40
42 On success, these functions return the next representable floating-
43 point value after x in the direction of y.
44
45 If x equals y, then y (cast to the same type as x) is returned.
46
47 If x or y is a NaN, a NaN is returned.
48
49 If x is finite, and the result would overflow, a range error occurs,
50 and the functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respec‐
51 tively, with the correct mathematical sign.
52
53 If x is not equal to y, and the correct function result would be sub‐
54 normal, zero, or underflow, a range error occurs, and either the cor‐
55 rect value (if it can be represented), or 0.0, is returned.
56
58 See math_error(7) for information on how to determine whether an error
59 has occurred when calling these functions.
60
61 The following errors can occur:
62
63 Range error: result overflow
64 An overflow floating-point exception (FE_OVERFLOW) is raised.
65
66 Range error: result is subnormal or underflows
67 An underflow floating-point exception (FE_UNDERFLOW) is raised.
68
69 These functions do not set errno.
70
72 C99, POSIX.1-2001. This function is defined in IEC 559 (and the appen‐
73 dix with recommended functions in IEEE 754/IEEE 854).
74
76 In glibc version 2.5 and earlier, these functions do not raise an
77 underflow floating-point (FE_UNDERFLOW) exception when an underflow
78 occurs.
79
81 nearbyint(3)
82
84 This page is part of release 3.22 of the Linux man-pages project. A
85 description of the project, and information about reporting bugs, can
86 be found at http://www.kernel.org/doc/man-pages/.
87
88
89
90GNU 2008-10-06 NEXTAFTER(3)