1NEXTAFTER(3)               Linux Programmer's Manual              NEXTAFTER(3)
2
3
4

NAME

6       nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl
7       - floating-point number manipulation
8

SYNOPSIS

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 <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
29
30       nextafterf(), nextafterl():
31           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
32               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
33               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
34
35       nexttoward(), nexttowardf(), nexttowardl():
36           _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
37               || _POSIX_C_SOURCE >= 200112L
38

DESCRIPTION

40       The nextafter(), nextafterf(), and nextafterl()  functions  return  the
41       next representable floating-point value following x in the direction of
42       y.  If y is less than x, these functions will return the largest repre‐
43       sentable number less than x.
44
45       If x equals y, the functions return y.
46
47       The  nexttoward(),  nexttowardf(),  and  nexttowardl() functions do the
48       same as the corresponding nextafter() functions, except that they  have
49       a long double second argument.
50

RETURN VALUE

52       On  success,  these  functions  return the next representable floating-
53       point value after x in the direction of y.
54
55       If x equals y, then y (cast to the same type as x) is returned.
56
57       If x or y is a NaN, a NaN is returned.
58
59       If x is finite, and the result would overflow, a  range  error  occurs,
60       and  the  functions  return  HUGE_VAL, HUGE_VALF, or HUGE_VALL, respec‐
61       tively, with the correct mathematical sign.
62
63       If x is not equal to y, and the correct function result would  be  sub‐
64       normal,  zero,  or underflow, a range error occurs, and either the cor‐
65       rect value (if it can be represented), or 0.0, is returned.
66

ERRORS

68       See math_error(7) for information on how to determine whether an  error
69       has occurred when calling these functions.
70
71       The following errors can occur:
72
73       Range error: result overflow
74              errno  is  set  to ERANGE.  An overflow floating-point exception
75              (FE_OVERFLOW) is raised.
76
77       Range error: result is subnormal or underflows
78              errno is set to ERANGE.  An underflow  floating-point  exception
79              (FE_UNDERFLOW) is raised.
80

ATTRIBUTES

82       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
83       tributes(7).
84
85       ┌────────────────────────────────────────────┬───────────────┬─────────┐
86Interface                                   Attribute     Value   
87       ├────────────────────────────────────────────┼───────────────┼─────────┤
88nextafter(), nextafterf(), nextafterl(),    │ Thread safety │ MT-Safe │
89nexttoward(), nexttowardf(), nexttowardl()  │               │         │
90       └────────────────────────────────────────────┴───────────────┴─────────┘
91

CONFORMING TO

93       C99,  POSIX.1-2001,  POSIX.1-2008.  This function is defined in IEC 559
94       (and the appendix with recommended functions in IEEE 754/IEEE 854).
95

BUGS

97       In glibc version 2.5 and earlier, these functions do not raise  an  un‐
98       derflow  floating-point  (FE_UNDERFLOW) exception when an underflow oc‐
99       curs.
100
101       Before glibc version 2.23 these functions did not set errno.
102

SEE ALSO

104       nearbyint(3)
105

COLOPHON

107       This page is part of release 5.12 of the Linux  man-pages  project.   A
108       description  of  the project, information about reporting bugs, and the
109       latest    version    of    this    page,    can     be     found     at
110       https://www.kernel.org/doc/man-pages/.
111
112
113
114GNU                               2021-03-22                      NEXTAFTER(3)
Impressum