1nextafter(3)               Library Functions Manual               nextafter(3)
2
3
4

NAME

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

LIBRARY

10       Math library (libm, -lm)
11

SYNOPSIS

13       #include <math.h>
14
15       double nextafter(double x, double y);
16       float nextafterf(float x, float y);
17       long double nextafterl(long double x, long double y);
18
19       double nexttoward(double x, long double y);
20       float nexttowardf(float x, long double y);
21       long double nexttowardl(long double x, long double y);
22
23   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
24
25       nextafter():
26           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
27               || _XOPEN_SOURCE >= 500
28               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
29               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
30
31       nextafterf(), nextafterl():
32           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
34               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
35
36       nexttoward(), nexttowardf(), nexttowardl():
37           _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
38               || _POSIX_C_SOURCE >= 200112L
39

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

STANDARDS

94       C11, POSIX.1-2008.
95
96       This  function is defined in IEC 559 (and the appendix with recommended
97       functions in IEEE 754/IEEE 854).
98

HISTORY

100       C99, POSIX.1-2001.
101

BUGS

103       In glibc 2.5 and earlier, these functions do  not  raise  an  underflow
104       floating-point (FE_UNDERFLOW) exception when an underflow occurs.
105
106       Before glibc 2.23 these functions did not set errno.
107

SEE ALSO

109       nearbyint(3)
110
111
112
113Linux man-pages 6.05              2023-07-20                      nextafter(3)
Impressum