nextafter(), nextafterf(), nextafterl() — Next representable double float
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2
C99 Single UNIX Specification, Version 3 C++ TR1 C99 |
both |
Format
#define _XOPEN_SOURCE_EXTENDED 1
#include <math.h>
double nextafter(double x, double y);
C99:
#define _ISOC99_SOURCE
#include <math.h>
float nextafterf(float x, float y);
long double nextafterl(long double x, long double y);
C++
TR1 C99:
#define _TR1_C99
#include <math.h>
float nextafter(float x, float y);
long double nextafter(long double x, long double y);
General description
The nextafter()
function computes the next representable double-precision floating-point
value following x in the direction of y.
Thus, if y is less than x,
nextafter() returns the largest representable floating-point number
less than x.
Note: The following table
shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE
Binary Floating-Point.
Function | Hex | IEEE |
---|---|---|
nextafter | X | X |
nextafterf | X | X |
nextafterl | X | X |
Restriction: The
nextafterf() function does not support the _FP_MODE_VARIABLE feature
test macro.
Returned value
The nextafter() functions return the next representable value following x in the direction of y. They always succeed.
If x is finite and the correct function value overflows, a range error occurs and ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL (with the same sign as x) are returned as appropriate for the return type of the function.
- Errno
- Descirption
- ERANGE
- The correct value overflows.