Determines the next value after x
in the direction of
y
that can be represented by the type of the function.
Include
<math.h>
Prototype
long double nextafterl(long double x, long double y);
Arguments
x
y
Return Value
Determines the next value after x
in the direction of
y
that can be represented by the type of the function. The value of
y
is returned if x
equals y
.
Remarks
A range error might occur if the magnitude of x
is the
largest finite value representable in the type and the result is infinite or not
representable in the type.
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
long double x,y,z;
x = 150.0;
y = 300.0;
z = nextafterl(x, y);
printf("The next representable value after %f in the direction of %f is %.20f\n", x, y, z);
x = 150.0;
y = -300.0;
z = nextafterl(x, y);
printf("The next representable value after %f in the direction of %f is %.20f\n", x, y, z);
}
Example Output
The next representable value after 150.000000 in the direction of 300.000000 is 150.00000000000002842171
The next representable value after 150.000000 in the direction of -300.000000 is 149.99999999999997157829