summaryrefslogtreecommitdiffstats
path: root/upstream/fedora-rawhide/man3/nextafter.3
blob: 51b770ff1e1eaa77a5b9a4cfd2a727a30f300ed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
'\" t
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\"     <mtk.manpages@gmail.com>
.\"
.\" SPDX-License-Identifier: GPL-1.0-or-later
.\"
.\" Based on glibc infopages
.\"
.TH nextafter 3 2023-10-31 "Linux man-pages 6.7"
.SH NAME
nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl \-
floating-point number manipulation
.SH LIBRARY
Math library
.RI ( libm ", " \-lm )
.SH SYNOPSIS
.nf
.B #include <math.h>
.P
.BI "double nextafter(double " x ", double " y );
.BI "float nextafterf(float " x ", float " y );
.BI "long double nextafterl(long double " x ", long double " y );
.P
.BI "double nexttoward(double " x ", long double " y );
.BI "float nexttowardf(float " x ", long double " y );
.BI "long double nexttowardl(long double " x ", long double " y );
.fi
.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
.P
.BR nextafter ():
.nf
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
        || _XOPEN_SOURCE >= 500
.\"    || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
        || /* Since glibc 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.P
.BR nextafterf (),
.BR nextafterl ():
.nf
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
        || /* Since glibc 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
.fi
.P
.BR nexttoward (),
.BR nexttowardf (),
.BR nexttowardl ():
.nf
    _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE
        || _POSIX_C_SOURCE >= 200112L
.fi
.SH DESCRIPTION
The
.BR nextafter (),
.BR nextafterf (),
and
.BR nextafterl ()
functions return the next representable floating-point value following
.I x
in the direction of
.IR y .
If
.I y
is less than
.IR x ,
these functions will return the largest representable number less than
.IR x .
.P
If
.I x
equals
.IR y ,
the functions return
.IR y .
.P
The
.BR nexttoward (),
.BR nexttowardf (),
and
.BR nexttowardl ()
functions do the same as the corresponding
.BR nextafter ()
functions, except that they have a
.I "long double"
second argument.
.SH RETURN VALUE
On success,
these functions return the next representable floating-point value after
.I x
in the direction of
.IR y .
.P
If
.I x
equals
.IR y ,
then
.I y
(cast to the same type as
.IR x )
is returned.
.P
If
.I x
or
.I y
is a NaN,
a NaN is returned.
.P
If
.I x
is finite,
.\" e.g., DBL_MAX
and the result would overflow,
a range error occurs,
and the functions return
.BR HUGE_VAL ,
.BR HUGE_VALF ,
or
.BR HUGE_VALL ,
respectively, with the correct mathematical sign.
.P
If
.I x
is not equal to
.IR y ,
and the correct function result would be subnormal, zero, or underflow,
a range error occurs,
and either the correct value (if it can be represented),
or 0.0, is returned.
.SH ERRORS
See
.BR math_error (7)
for information on how to determine whether an error has occurred
when calling these functions.
.P
The following errors can occur:
.TP
Range error: result overflow
.\" e.g., nextafter(DBL_MAX, HUGE_VAL);
.I errno
is set to
.BR ERANGE .
An overflow floating-point exception
.RB ( FE_OVERFLOW )
is raised.
.TP
Range error: result is subnormal or underflows
.\" e.g., nextafter(DBL_MIN, 0.0);
.I errno
is set to
.BR ERANGE .
An underflow floating-point exception
.RB ( FE_UNDERFLOW )
is raised.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.na
.nh
.BR nextafter (),
.BR nextafterf (),
.BR nextafterl (),
.BR nexttoward (),
.BR nexttowardf (),
.BR nexttowardl ()
T}	Thread safety	MT-Safe
.TE
.SH STANDARDS
C11, POSIX.1-2008.
.P
This function is defined in IEC 559 (and the appendix with
recommended functions in IEEE 754/IEEE 854).
.SH HISTORY
C99, POSIX.1-2001.
.SH BUGS
In glibc 2.5 and earlier, these functions do not raise an underflow
floating-point
.RB ( FE_UNDERFLOW )
exception when an underflow occurs.
.P
Before glibc 2.23
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6799
these functions did not set
.IR errno .
.SH SEE ALSO
.BR nearbyint (3)