The nextafterl()
function produces the smallest possible value after a number in a given direction. The declaration of nextafterl()
is shown below:
long double nextafterl (long double num, long double dir);
num
: The base numberdir
: The direction of the floating point with respect to num
.The nextafterl()
function returns the next representable floating-point number after num
in the direction of dir
.
To use the nextafterl()
function, include the following library:
#include <math.h>
Consider the code snippet below, which demonstrates the implementation of nextafterl()
:
#include <stdio.h>#include <math.h>int main() {double a = 0.0;double b = 1.0;double x = nextafter(a, b);printf("nextafterl ( %f, %f ) = ( %e ) \n", a, b, x);return 0;}
The nextafterl()
function is used in line 9 to compute the next representable floating-point number after a
in the direction of b
.
Free Resources