nextafter
Return the next representable value of the specified return format after x in the direction of y.
Interface Definition
C interface:
float nextafterf(float x, float y);
double nextafter(double x, double y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- The next representable value of the specified return format after x in the direction of y is returned.
- errno: ERANGE is returned in overflow scenarios.
- The special values are listed in the following table.
Input Value (x)
Input Value (y)
Output Value (result)
Non-NaN value
nan
nan
nan
Non-NaN value
nan
nan
nan
nan
inf
inf
inf
-inf
-inf
-inf
inf
-inf
0x7fefffffffffffff(double)
0x7f7fffff(float)
-inf
inf
0xffefffffffffffff(double)
0xff7fffff(float)
Dependency
C: "km.h"
Example
C interface:
1 2 3 4 5 6 7 8 9 | // typical usage double x1 = 1.0, y1 = 2.0, x2 = 3.0, y2 = 4.0; // print result printf("nextafter(x1, y1) = %.15f\n", nextafter(x1, y1)); printf("nextafter(x2, y2) = %.15f\n", nextafter(x2, y2)); /* * nextafter(x1, y1) = 1.000000000000000 * nextafter(x2, y2) = 3.000000000000000 */ |
Parent topic: Miscellaneous Functions