NEXTAFTER(3POSIX)
NEXTAFTER(3POSIX) π
okay bestie, welcome to the POSIX Programmer's Manual, page NEXTAFTER(3POSIX), brought to you by IEEE/The Open Group circa 2017 β¨
Heads up babes π this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go peek at the corresponding Linux manual page for the deets on Linux behavior), or the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl β next representable floating-point number π¦
π SYNOPSIS π
#include <math.h>
double nextafter(double x, double y);
float nextafterf(float x, float y);
long double nextafterl(long double x, long double y);
double nexttoward(double x, long double y);
float nexttowardf(float x, long double y);
long double nexttowardl(long double x, long double y);
π DESCRIPTION π
So the functionality described on this reference page is aligned with the ISO C standard. If there's any conflict between the requirements described here and the ISO C standard, that's unintentional, okay?? This volume of POSIX.1β2017 defers to the ISO C standard. periodt. π
The nextafter(), nextafterf(), and nextafterl() functions shall compute the next representable floating-point value following x in the direction of y. So like β if y is less than x, then nextafter() shall return the largest representable floating-point number less than x. And the nextafter(), nextafterf(), and nextafterl() functions shall return y if x equals y. π«
The nexttoward(), nexttowardf(), and nexttowardl() functions shall be equivalent to the corresponding nextafter() functions, except that the second parameter shall have type long double and the functions shall return y converted to the type of the function if x equals y. it's giving "same vibe, different type" fr fr π«Ά
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. π
πΈ RETURN VALUE πΈ
Upon successful completion, these functions shall return the next representable floating-point value following x in the direction of y. β¨
If x==y, y (of the type x) shall be returned.
If x is finite and the correct function value would overflow, a range error shall occur and Β±HUGE_VAL, Β±HUGE_VALF, and Β±HUGE_VALL (with the same sign as x) shall be returned as appropriate for the return type of the function. π
If x or y is NaN, a NaN shall be returned. π
If x!=y and the correct function value is subnormal, zero, or underflows, a range error shall occur, and the correct function value (if representable) or 0.0 shall be returned.
π₯ ERRORS π₯
These functions shall fail if:
- Range Error β The correct value overflows. If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the overflow floating-point exception shall be raised. - Range Error β The correct value is subnormal or underflows. If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the underflow floating-point exception shall be raised.
ngl bestie, the following sections are informative. so like, informative-only energy. π
π§ EXAMPLES π§
None. (yeah. literally nothing. iconic of them honestly π )
π APPLICATION USAGE π
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero.
When <tgmath.h> is included, note that the return type of nextafter() depends on the generic typing deduced from both arguments, while the return type of nexttoward() depends only on the generic typing of the first argument. ikyk π
π¦ RATIONALE π¦
None.
β FUTURE DIRECTIONS β
None.
π SEE ALSO π
feclearexcept()fetestexcept()
The Base Definitions volume of POSIX.1β2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, <math.h>, <tgmath.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole page bestie, mwah π this was IEEE/The Open Group, 2017, NEXTAFTER(3POSIX) β stay floating, stay representable, and don't forget to clear those exceptions before you call. slay π«Άβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms